Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

4.6.0 fails to build on big-endian architectures: undefined reference to `byteswap8' #806

Closed
sebastic opened this issue Jan 25, 2018 · 7 comments · Fixed by #1302
Closed

Comments

@sebastic
Copy link
Contributor

NetCDF 4.6.0 fails to build on big-endian architectures:

[ 30%] Linking C executable ncgen3
cd /<<PKGBUILDDIR>>/obj-mips-linux-gnu/ncgen3 && /usr/bin/cmake -E cmake_link_script CMakeFiles/ncgen3.dir/link.txt --verbose=1
/usr/bin/cc -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Wl,-z,relro -Wl,-z,now CMakeFiles/ncgen3.dir/main.c.o CMakeFiles/ncgen3.dir/load.c.o CMakeFiles/ncgen3.dir/escapes.c.o CMakeFiles/ncgen3.dir/getfill.c.o CMakeFiles/ncgen3.dir/init.c.o CMakeFiles/ncgen3.dir/genlib.c.o CMakeFiles/ncgen3.dir/ncgentab.c.o  -o ncgen3 -Wl,-rpath,/<<PKGBUILDDIR>>/obj-mips-linux-gnu/liblib:/usr/lib/mips-linux-gnu/hdf5/serial: ../liblib/libnetcdf.so.13 /usr/lib/mips-linux-gnu/hdf5/serial/libhdf5_hl.so /usr/lib/mips-linux-gnu/hdf5/serial/libhdf5.so -lpthread /usr/lib/mips-linux-gnu/libsz.so /usr/lib/mips-linux-gnu/libz.so /usr/lib/mips-linux-gnu/libdl.so /usr/lib/mips-linux-gnu/libm.so /usr/lib/mips-linux-gnu/libcurl.so 
../liblib/libnetcdf.so.13: undefined reference to `byteswap8'
collect2: error: ld returned 1 exit status

Buildlogs: mips, s390x

@DennisHeimbigner
Copy link
Collaborator

Unfortunately, we do not have a big-endian machine against which to test.
So things like this can slip thru. I will create a fix, but you may have
to test it out for me.

@DennisHeimbigner
Copy link
Collaborator

P.S. there is also a known bug when using dap4 on a big-endian machine.

@sebastic
Copy link
Contributor Author

This patch fixes the issue on the s390x porterbox:

--- a/libdispatch/dfilter.c
+++ b/libdispatch/dfilter.c
@@ -156,7 +156,7 @@ NC_parsefilterspec(const char* spec, uns
            /* convert to network byte order */
            memcpy(mem,&val64u,sizeof(mem));
 #ifdef WORDS_BIGENDIAN     
-           byteswap8(mem);  /* convert big endian to little endian */
+           NC_byteswap8(mem);  /* convert big endian to little endian */
 #endif
            vector = (unsigned int*)mem;
            ulist[nparams++] = vector[0];

@DennisHeimbigner
Copy link
Collaborator

Ok, that is the same fix I was going to ask you to test. So I will just go ahead
and turn it into a pull request.

DennisHeimbigner added a commit that referenced this issue Jan 25, 2018
Incorrect reference to byteswap8 in libdispatch/dfilter.c
Change byteswap8 -> NC_byteswap8.
@t-b
Copy link
Contributor

t-b commented Jan 5, 2019

I could compile latest master on mips successfully, so I guess this can be closed.

@DennisHeimbigner
Copy link
Collaborator

Did make check work also?

@t-b
Copy link
Contributor

t-b commented Jan 6, 2019

@DennisHeimbigner Your are too fast ;) Nope, see #1278.

DennisHeimbigner added a commit that referenced this issue Feb 1, 2019
re: issue #1278
re: issue #876
re: issue #806

* Major change to the handling of 8-byte parameters for nc_def_var_filter.
  The old code was not well thought out.
  * The new algorithm is documented in docs/filters.md.
  * Added new utility file plugins/H5Zutil.c to support
  * Modified plugins/H5Zmisc.c to use new algorithm
  the new algorithm.
  * Renamed include/ncfilter.h to include/netcdf_filter.h
    and made it an installed header so clients can access the
    new algorithm utility.
  * Fixed nc_test4/tst_filterparser.c and nc_test4/test_filter_misc.c
    to use the new algorithm
* libdap4/ fixes:
  * d4swap.c has an error in the endian pre-processing such
    that record counts were not being swapped correctly.
  * d4data.c had an error in that checksums were being computed
    after endian swapping rather than before.
* ocinitialize() was never being called, so xxdr bigendian handling
  was never set correctly.
  * Required adding debug statements to occompile
* Found and fixed memory leak in ncdump.c

Not tested:
* HDF4
* Pnetcdf
* parallel HDF5
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants