Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ranlib should be run on static libs on macOS: ld: in dbarts.a, archive has no table of contents #55

Open
barracuda156 opened this issue Apr 12, 2023 · 12 comments

Comments

@barracuda156
Copy link

ar rv ../dbarts.a bartFit.o binaryIO.o birthDeathRule.o changeRule.o functions.o likelihood.o node.o parameterPrior.o state.o swapRule.o tree.o treePrior.o
ar: creating archive ../dbarts.a
a - bartFit.o
a - binaryIO.o
a - birthDeathRule.o
a - changeRule.o
a - functions.o
a - likelihood.o
a - node.o
a - parameterPrior.o
a - state.o
a - swapRule.o
a - tree.o
a - treePrior.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c io.c -o io.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c randomBase.c -o randomBase.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c randomNorm.c -o randomNorm.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c random.c -o random.o
ar rv ../external.a io.o randomBase.o randomNorm.o random.o
ar: creating archive ../external.a
a - io.o
a - randomBase.o
a - randomNorm.o
a - random.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC  -c adaptiveRadixTree.c -o adaptiveRadixTree.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c binaryIO.c -o binaryIO.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c blockingThreadManager.c -o blockingThreadManager.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c hierarchicalThreadManager.c -o hierarchicalThreadManager.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c linearAlgebra.c -o linearAlgebra.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c moments.c -o moments.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c partition.c -o partition.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c simd.c -o simd.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c string.c -o string.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include   -fPIC  -pipe -Os -arch ppc  -fPIC -c thread.c -o thread.o
ar rv ../misc.a adaptiveRadixTree.o binaryIO.o blockingThreadManager.o hierarchicalThreadManager.o linearAlgebra.o moments.o partition.o simd.o string.o thread.o 
ar: creating archive ../misc.a
a - adaptiveRadixTree.o
a - binaryIO.o
a - blockingThreadManager.o
a - hierarchicalThreadManager.o
a - linearAlgebra.o
a - moments.o
a - partition.o
a - simd.o
a - string.o
a - thread.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include  -pipe -Os -arch ppc  -fPIC -c bounds.c -o bounds.o
/opt/local/bin/gcc-mp-12 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../include -pthread  -isystem/opt/local/include/LegacySupport -I/opt/local/include  -pipe -Os -arch ppc  -fPIC -c util.c -o util.o
ar rv ../rc.a bounds.o util.o
ar: creating archive ../rc.a
a - bounds.o
a - util.o
/opt/local/bin/g++-mp-12 -std=gnu++14 -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 -Wl,-rpath,/opt/local/lib/libgcc -L/opt/local/lib -lMacportsLegacySupport -arch ppc -o dbarts.so R_C_interface.o R_interface.o R_interface_common.o R_interface_crossvalidate.o R_interface_rbart.o R_interface_sampler.o crossvalidate.o guessNumCores.o makeModelMatrixFromDataFrame.o dbarts.a external.a misc.a rc.a -pthread -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: in dbarts.a, archive has no table of contents
collect2: error: ld returned 1 exit status
make: *** [dbarts.so] Error 1
@barracuda156 barracuda156 changed the title ranlib should be run on static libson macOS: ld: in dbarts.a, archive has no table of contents ranlib should be run on static libs on macOS: ld: in dbarts.a, archive has no table of contents Apr 12, 2023
@barracuda156
Copy link
Author

This fixes the build:

--- src/dbarts/Makefile.orig	2023-01-21 01:54:34.000000000 +0800
+++ src/dbarts/Makefile	2023-04-13 05:47:53.000000000 +0800
@@ -13,6 +13,7 @@
 
 library : $(LOCAL_OBJECTS)
 	$(AR) $(ARFLAGS) ../dbarts.a $(LOCAL_OBJECTS)
+	$(RANLIB) ../dbarts.a
 
 clean :
 	@-rm -f config.hpp

--- src/external/Makefile.orig	2023-01-21 01:54:34.000000000 +0800
+++ src/external/Makefile	2023-04-13 05:48:13.000000000 +0800
@@ -9,6 +9,7 @@
 
 library : $(LOCAL_OBJECTS)
 	$(AR) $(ARFLAGS) ../external.a $(LOCAL_OBJECTS)
+	$(RANLIB) ../external.a
 
 clean :
 	@-rm -f config.h

--- src/misc/Makefile.orig	2023-01-21 01:54:34.000000000 +0800
+++ src/misc/Makefile	2023-04-13 05:48:41.000000000 +0800
@@ -57,6 +57,7 @@
 
 library : $(LOCAL_OBJECTS)
 	$(AR) $(ARFLAGS) ../misc.a $(LOCAL_OBJECTS)
+	$(RANLIB) ../misc.a
 
 clean :
 	@-rm -f config.h

--- src/rc/Makefile.orig	2023-01-21 01:54:34.000000000 +0800
+++ src/rc/Makefile	2023-04-13 05:48:57.000000000 +0800
@@ -9,6 +9,7 @@
 
 library : $(LOCAL_OBJECTS)
 	$(AR) $(ARFLAGS) ../rc.a $(LOCAL_OBJECTS)
+	$(RANLIB) ../rc.a
 
 clean :
 	@-rm -f config.h

I am not sure if this can be used unconditionally for every OS though.

@barracuda156
Copy link
Author

As an alternative, fixing flags for ar so that table of contents is generated will likely work too.

@vdorie
Copy link
Owner

vdorie commented Dec 10, 2023 via email

@barracuda156
Copy link
Author

barracuda156 commented Dec 18, 2023

@vdorie s is needed in ar flags in order for that to work across all platforms. I.e., cr will not be sufficient, crs will.

P. S. Here the identical problem was fixed via adding s: PolMine/RcppCWB@c6df1cc

@vdorie
Copy link
Owner

vdorie commented Dec 18, 2023

Thank you! I added s to the defaults in dd206c4 and it'll be included in the next push to CRAN.

@barracuda156
Copy link
Author

@vdorie Thank you, awesome!

@barracuda156
Copy link
Author

@vdorie Does not work still with 0.9-26:

ar rv ../rc.a bounds.o util.o
ar: creating archive ../rc.a
a - bounds.o
a - util.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 dbarts.so R_C_interface.o R_interface.o R_interface_common.o R_interface_crossvalidate.o R_interface_rbart.o R_interface_sampler.o crossvalidate.o guessNumCores.o makeModelMatrixFromDataFrame.o dbarts.a external.a misc.a rc.a -pthread -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: in dbarts.a, archive has no table of contents
collect2: error: ld returned 1 exit status
make: *** [dbarts.so] Error 1

@barracuda156 barracuda156 reopened this Feb 4, 2024
@vdorie
Copy link
Owner

vdorie commented Feb 8, 2024 via email

@barracuda156
Copy link
Author

@vdorie Did the last CRAN release have s added to ar flags? That should work, and it is according to ar documentation (nothing exclusive to macOS). It looks like newer versions of ar pretend the flag was passed even if it was not, and generate the table regardless. I do not see any reason to do it conditionally, to be honest.

@vdorie
Copy link
Owner

vdorie commented Feb 8, 2024 via email

@barracuda156
Copy link
Author

barracuda156 commented Feb 9, 2024

In the version on CRAN the flags should default to "-crs" unless ARFLAGS is non-empty, so if it is still failing that might be why. It looks like the flags are set to 'rv', right?

Hmm, interesting. I definitely did not pass arflags manually. I also do not think Macports should be passing that.

@barracuda156
Copy link
Author

We do use CRAN version: https://github.com/macports/macports-ports/blob/7518a78ed00d82d1e8164258d7f921cfbf421c28/R/R-dbarts/Portfile#L7

It still fails without a patch adding ranlib. Here are logs:
dbarts_as_is.txt
dbarts_patched.txt
I do not think anything in Macports resets AR flags, that does not happen with other ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants