qsbase / qs

Quick serialization of R objects
405 stars 19 forks source link

New check for `libatomic` in 0.26.3 does not work #98

Open barracuda156 opened 6 months ago

barracuda156 commented 6 months ago

After https://github.com/traversc/qs/issues/88 we have this broken again for systems where libatomic has to be linked. Configure check does not work correctly.

--->  Extracting qs_0.26.3.tar.gz
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work" && /usr/bin/gzip -dc '/opt/local/var/macports/distfiles/R-qs/qs_0.26.3.tar.gz' | /usr/bin/gnutar --no-same-owner -xf - 
--->  Configuring R-qs
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/qs" && /opt/local/bin/R CMD build . --no-manual --no-build-vignettes --keep-empty-dirs 
* checking for file ‘./DESCRIPTION’ ... OK
* preparing ‘qs’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* running ‘cleanup’
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘qs_0.26.3.tar.gz’

--->  Building R-qs
xinstall: mkdir /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/qs" && /opt/local/bin/R CMD INSTALL . --library=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build --install-tests 
* installing *source* package ‘qs’ ...
** package ‘qs’ successfully unpacked and MD5 sums checked
** using staged installation
checking for pkg-config... /opt/local/bin/pkg-config
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether /opt/local/bin/g++-mp-13 -std=gnu++17 accepts -g... yes
C++ compiler: /opt/local/bin/g++-mp-13 -std=gnu++17
Does not require -latomic flag
zstd 1.5.6 library detected -- skipping zstd compilation
lz4 1.9.4 library detected -- skipping lz4 compilation
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘g++-mp-13 (MacPorts gcc13 13.2.0_4+stdlib_flag) 13.2.0’
Warning in system2("xcrun", "--show-sdk-path", TRUE, TRUE) :
  running command ''xcrun' --show-sdk-path 2>&1' had status 64
using SDK: ‘NA’‘NA’‘NA’‘NA’‘NA’‘NA’
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I.    -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RApiSerialize/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/stringfish/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc   -c RcppExports.cpp -o RcppExports.o
/opt/local/bin/g++-mp-13 -std=gnu++17 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DRCPP_USE_UNWIND_PROTECT -DRCPP_NO_RTTI -DRCPP_NO_SUGAR -I.    -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/Rcpp/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/RApiSerialize/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/stringfish/include' -I'/opt/local/Library/Frameworks/R.framework/Versions/4.4/Resources/library/BH/include' -isystem/opt/local/include/LegacySupport -I/opt/local/include    -fPIC  -pipe -Os -arch ppc   -c qs_functions.cpp -o qs_functions.o
/opt/local/bin/g++-mp-13 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/lib -Wl,-headerpad_max_install_names -L/opt/local/lib -lMacportsLegacySupport -Wl,-rpath,/opt/local/lib/libgcc -arch ppc -o qs.so RcppExports.o qs_functions.o -L. -lpthread -L/opt/local/lib -lzstd -L/opt/local/lib -llz4 -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build/00LOCK-qs/00new/qs/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘qs’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build/00LOCK-qs/00new/qs/libs/qs.so':
  dlopen(/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build/00LOCK-qs/00new/qs/libs/qs.so, 6): Symbol not found: ___atomic_store_8
  Referenced from: /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build/00LOCK-qs/00new/qs/libs/qs.so
  Expected in: dynamic lookup

Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build/qs’
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/qs" && /opt/local/bin/R CMD INSTALL . --library=/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-qs/R-qs/work/build --install-tests 
Exit code: 1
Error: Failed to build R-qs: command execution failed
traversc commented 6 months ago

Sorry about that. Will need your help troubleshooting this one (again).

In the other issue you mentioned that we needed to check for 8-byte atomics but the configure file is testing for it:

https://github.com/traversc/qs/blob/4798f3c68aff8e0d5004ff544ed70c0db2433474/configure.ac#L64

Does that small test program compile separately with g++?

barracuda156 commented 6 months ago

@traversc Yes, ppc (as well as some other 32-bit archs) do not have native 64-bit atomics. It has been the case and nothing changed or will change here.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81283#c2

I will try to compile that tomorrow. Something does not work as intended with the check, but we have to find out what exactly.

barracuda156 commented 6 months ago

@traversc Sorry for a delay. I have tried now to compile a standalone snippet, and no, it fails, as it should:

36-244% /opt/local/bin/g++-mp-13 test_qs.cpp -o test_qs
Undefined symbols:
  "___atomic_fetch_add_8", referenced from:
      _main in ccak9Rx8.o
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
traversc commented 6 months ago

If you add some random gibberish to break the test program in the config file here:

https://github.com/traversc/qs/blob/4798f3c68aff8e0d5004ff544ed70c0db2433474/configure#L2414

will it still say Does not require -latomic flag? I don't understand why it compiles from the config file but not independently.

Also, do you know if its possible to set up a VM? I'm guessing no since it is a mac.

barracuda156 commented 6 months ago

@traversc VM is certainly possible since I have it myself on an Intel machine.

I use Parallels with Snow Leopard Server and I can build and run ppc binaries via Rosetta. There are open-source alternatives like UTM.