Open jkyang92 opened 4 years ago
This is tangentially related to #1412. I think instead of hardcoding addresses, autotools should check if brew exists and if so ask for its prefix using brew --prefix
.
Okay, I'll fix that. We'll let the user add /usr/local/lib if necessary. And maybe have a configure option "--enable-homebrew" that takes the brew file location into account. The default for that could be "yes", I suppose.
While on this topic, the following lines also look hardcoded: https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L772 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L793 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L829 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L846 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L867 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L886 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L933 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L955 https://github.com/Macaulay2/M2/blob/a4d50d7ac77e7609b391ae6760e96995a5e46ccd/M2/configure.ac#L1112-L1115
Yes, I regretted having to do that. If only there were a better way to find static libraries.
Yes, I regretted having to do that. If only there were a better way to find static libraries.
CMake 😅
Seriously, what if finding and building libraries was done by CMake even when using the autotools build? The idea is to have CMake build everything that needs to be built in usr-host, then Makefiles can just look there.
How does cmake find static libraries? Do they know something I don't?
How does cmake find static libraries? Do they know something I don't?
https://cmake.org/cmake/help/latest/command/find_library.html
Thanks. I looked a bit at the source code, and it seems to discover the path used by the linker and just look there.
Maybe it does it this way:
$ cc -Wl,-v foo.c -lm
@(#)PROGRAM:ld PROJECT:ld64-556.6
BUILD 18:54:40 Jun 2 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
/usr/local/lib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
Framework search paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/
$ type gcc
gcc is /usr/bin/gcc
$ gcc-10 -Wl,-v foo.c -lm
collect2 version 10.1.0
/usr/bin/ld -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/ -dynamic -arch x86_64 -macosx_version_min 10.15.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/brew-root/Cellar/gcc/10.1.0/bin/../lib/gcc/10/gcc/x86_64-apple-darwin19/10.1.0 -L/usr/local/brew-root/Cellar/gcc/10.1.0/bin/../lib/gcc/10/gcc -L/usr/local/brew-root/Cellar/gcc/10.1.0/bin/../lib/gcc/10/gcc/x86_64-apple-darwin19/10.1.0/../../.. -v /var/folders/hq/7lqcg89j1pq8m9vq_333xfwh0000gn/T//ccLfSwce.o -lSystem -lgcc_ext.10.5 -lgcc -lSystem -no_compact_unwind
@(#)PROGRAM:ld PROJECT:ld64-556.6
BUILD 18:54:40 Jun 2 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
/usr/local/brew-root/Cellar/gcc/10.1.0/lib/gcc/10/gcc/x86_64-apple-darwin19/10.1.0
/usr/local/brew-root/Cellar/gcc/10.1.0/lib/gcc/10/gcc
/usr/local/brew-root/Cellar/gcc/10.1.0/lib/gcc/10
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib
Framework search paths:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/
$ gcc-9 -Wl,-v foo.c -lm
collect2 version 9.3.0
/usr/bin/ld -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/ -dynamic -arch x86_64 -macosx_version_min 10.15.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/brew-root/Cellar/gcc@9/9.3.0/bin/../lib/gcc/9/gcc/x86_64-apple-darwin19/9.3.0 -L/usr/local/brew-root/Cellar/gcc@9/9.3.0/bin/../lib/gcc/9/gcc -L/usr/local/brew-root/Cellar/gcc@9/9.3.0/bin/../lib/gcc/9/gcc/x86_64-apple-darwin19/9.3.0/../../.. -v /var/folders/hq/7lqcg89j1pq8m9vq_333xfwh0000gn/T//ccjakNGn.o -lSystem -lgcc_ext.10.5 -lgcc -lSystem -no_compact_unwind
@(#)PROGRAM:ld PROJECT:ld64-556.6
BUILD 18:54:40 Jun 2 2020
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
/usr/local/brew-root/Cellar/gcc@9/9.3.0/lib/gcc/9/gcc/x86_64-apple-darwin19/9.3.0
/usr/local/brew-root/Cellar/gcc@9/9.3.0/lib/gcc/9/gcc
/usr/local/brew-root/Cellar/gcc@9/9.3.0/lib/gcc/9
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib
Framework search paths:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/
In any case, I could do it that way.
Yes, you could re-implement cmake, but it already exists and comes with regular updates and support for various platforms, compilers, and IDEs.
Well, no, it wouldn't be a re-implementation of cmake.
Running into issues related to the hardcoded paths again: https://github.com/Macaulay2/M2/blob/b454d9ed0def9307eef21f7cdfdccc626233d033/M2/configure.ac#L61-L63
This is not very smart.
If that is not good, how does one fix that? I seemed to have problems also with the cmake build with this issue (finding tbb).
I don't know what issue about tbb you're referring to. My problem is that I have an older version of flint in /usr/lib
and the correct version in /usr/local/lib
, which causes build failures.
Running into issues related to the hardcoded paths again: https://github.com/Macaulay2/M2/blob/b454d9ed0def9307eef21f7cdfdccc626233d033/M2/configure.ac#L61-L63
Maybe /usr and /usr/local should be in the opposite order, so /usr/local stuff is found first.
Despite https://github.com/Macaulay2/M2/commit/690d18157bbf0efd25381bcbda27707d0ee95d6c, still have issues with this, this time with the incorrect openmp library being used .. I give up.
See commit e2b8aaeefc2ecb26508e46505a6d96c09def159d
The following line in configure.ac line 61 causes configure issues on Gentoo:
LDFLAGS="$LDFLAGS -L/usr/lib -L/usr/local/lib"
This is since the multilib layout is different than most systems. In particular 32bit libraries are in
/lib
and/usr/lib
. See https://wiki.gentoo.org/wiki/Project:AMD64/Multilib_layout. It seems from the comment in configure.ac that this line is for homebrew based compilers? Do we have a good way to restrict to homebrew based compilers? Would it be reasonable to just restrict this line to MacOS?