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

Module configuration broken on macOS-arm64 #2422

Closed
dchristiaens opened this issue Jan 30, 2022 · 5 comments
Closed

Module configuration broken on macOS-arm64 #2422

dchristiaens opened this issue Jan 30, 2022 · 5 comments

Comments

@dchristiaens
Copy link
Member

There appears to be an issue with developer module support on macOS-arm64. (Obviously related to #2247 but starting a new thread because the other one is long enough already.)

MRtrix3 installed from source, using default ./configure & ./build with Qt5 and Eigen installed through homebrew. To reproduce the issue:

➜  ~ mkdir -p test-module/cmd 
➜  ~ cd test-module
➜  test-module cp ../mrtrix3/cmd/tckinfo.cpp cmd/
➜  test-module ln -s ../mrtrix3/build
➜  test-module ./build

produces a long list of linker issues, all to do with the target architecture. From build.log:

...
  (1/3) [CC] tmp/cmd/tckinfo.o
 clang++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -DMRTRIX_MACOSX -fPIC -mmacosx-version-min=12.1 -DMRTRIX_WORD64 -DMRTRIX_HAVE_EIGEN_UNSUPPORTED_SPECIAL_FUNCTIONS -Wall -O3 -DNDEBUG -DMRTRIX_PROJECT -Isrc -I../mrtrix3/src -I../mrtrix3/core -Icmd -idirafter /opt/homebrew/Cellar/eigen/  3.4.0_1/include/eigen3 -DEIGEN_DONT_PARALLELIZE cmd/tckinfo.cpp -o tmp/cmd/tckinfo.o
 (2/3) [CC] tmp/src/project_version.o
 clang++ -c -std=c++11 -DMRTRIX_BUILD_TYPE="release version" -DMRTRIX_MACOSX -fPIC -mmacosx-version-min=12.1 -DMRTRIX_WORD64 -DMRTRIX_HAVE_EIGEN_UNSUPPORTED_SPECIAL_FUNCTIONS -Wall -O3 -DNDEBUG -DMRTRIX_PROJECT -Isrc -I../mrtrix3/src -I../mrtrix3/core -Icmd -idirafter /opt/homebrew/Cellar/eigen/  3.4.0_1/include/eigen3 -DEIGEN_DONT_PARALLELIZE src/project_version.cpp -o tmp/src/project_version.o
 (3/3) [LB] bin/tckinfo
 clang++ ../mrtrix3/tmp/src/dwi/tractography/rng.o ../mrtrix3/tmp/src/exec_version.o ../mrtrix3/tmp/src/dwi/tractography/file_base.o tmp/src/project_version.o ../mrtrix3/   tmp/src/dwi/tractography/roi.o ../mrtrix3/tmp/src/dwi/tractography/properties.o ../mrtrix3/tmp/src/dwi/tractography/seeding/list.o tmp/cmd/tckinfo.o -lmrtrix -mmacosx-version-min=12.1 -lz -Wl,-rpath,@loader_path/../../mrtrix3/lib -L../mrtrix3/lib -o bin/tckinfo

 ERROR: (3/3) [LB] bin/tckinfo

 clang++ ../mrtrix3/tmp/src/dwi/tractography/rng.o ../mrtrix3/tmp/src/exec_version.o ../mrtrix3/tmp/src/dwi/tractography/file_base.o tmp/src/project_version.o ../mrtrix3/   tmp/src/dwi/tractography/roi.o ../mrtrix3/tmp/src/dwi/tractography/properties.o ../mrtrix3/tmp/src/dwi/tractography/seeding/list.o tmp/cmd/tckinfo.o -lmrtrix -mmacosx-version-min=12.1 -lz -Wl,-rpath,@loader_path/../../mrtrix3/lib -L../mrtrix3/lib -o bin/tckinfo

 failed with output

 ld: warning: ignoring file ../mrtrix3/tmp/src/exec_version.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
 ld: warning: ignoring file ../mrtrix3/tmp/src/dwi/tractography/rng.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
 ld: warning: ignoring file ../mrtrix3/tmp/src/dwi/tractography/file_base.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
 ld: warning: ignoring file ../mrtrix3/tmp/src/dwi/tractography/roi.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
 ld: warning: ignoring file ../mrtrix3/tmp/src/dwi/tractography/seeding/list.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
 ld: warning: ignoring file ../mrtrix3/tmp/src/dwi/tractography/properties.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
 ld: warning: ignoring file ../mrtrix3/lib/libmrtrix.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 Undefined symbols for architecture x86_64:
   "MR::ProgressBar::display_func", referenced from:
       run() in tckinfo.o
   "MR::ProgressBar::progressbar_active", referenced from:
       run() in tckinfo.o
...

The compiler and linker commands are identical to those in ../mrtrix3/build.log, so I don't understand why the module is trying to build x86 binaries when their (shared) config is set up to build for arm64. Any ideas I while keep digging?

@jdtournier
Copy link
Member

jdtournier commented Jan 30, 2022

Have you tried a ./build clean in the base MRtrix install? It looks like there may be some old objects generated from the base src/ folder that may have been built for a different target, potentially with a different config at the time?

@dchristiaens
Copy link
Member Author

It's a fresh install.. The only "fix" I've found so far is to build with a ./configure -nogui, so it appears to be Qt-related.

Oddly though, after doing this, a new ./configure call also fails on a similar linking error:

EXEC <<
 CMD: clang++ -mmacosx-version-min=12.2 -lz qt_moc.o qt.o -o qt -stdlib=libc++ -headerpad_max_install_names -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-    min=12.2 -Wl,-rpath,@executable_path/../Frameworks -F/opt/homebrew/Cellar/qt@5/5.15.2_1/lib -framework QtOpenGL -framework QtSvg -framework QtWidgets -framework QtGui -framework AppKit -    framework Metal -framework QtNetwork -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL
 EXIT: 1
 STDERR:
 ld: warning: ignoring file /opt/homebrew/Cellar/qt@5/5.15.2_1/lib/QtOpenGL.framework/QtOpenGL, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 ld: warning: ignoring file /opt/homebrew/Cellar/qt@5/5.15.2_1/lib/QtSvg.framework/QtSvg, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 ld: warning: ignoring file /opt/homebrew/Cellar/qt@5/5.15.2_1/lib/QtWidgets.framework/QtWidgets, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 ld: warning: ignoring file /opt/homebrew/Cellar/qt@5/5.15.2_1/lib/QtGui.framework/QtGui, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 ld: warning: ignoring file /opt/homebrew/Cellar/qt@5/5.15.2_1/lib/QtNetwork.framework/QtNetwork, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 ld: warning: ignoring file /opt/homebrew/Cellar/qt@5/5.15.2_1/lib/QtCore.framework/QtCore, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 Undefined symbols for architecture x86_64:
...

Clearly, something has changed in my Qt/Homebrew setup between yesterday and today. Though I can't think what it could be...

@dchristiaens
Copy link
Member Author

OK, another clue:

/usr/bin/python2
Python 2.7.18
➜  mrtrix3 git:(master) python2 configure && python2 build

runs fine, and the test module compiles too, whereas

➜  mrtrix3 git:(master) which python; python --version
/opt/homebrew/anaconda3/bin/python
Python 3.9.7
➜  mrtrix3 git:(master) ./configure

fails on linking Qt. In the latter case, configure also doesn't find libtiff, libpng, and FFTW.

Given that configure and build are extensively tested on Python 3.x by now, the issue seems to be related with Anaconda (which I installed last night). Anaconda indeed seems to ship x86_64 binaries, though these should be ignored by ./configure

➜  ~ file $(which qmake)
/opt/homebrew/opt/qt@5/bin/qmake: Mach-O 64-bit executable arm64
➜  ~ file /opt/homebrew/anaconda3/bin/qmake
/opt/homebrew/anaconda3/bin/qmake: Mach-O 64-bit executable x86_64

It is worrying that Anacona's python somehow steers the linker towards its own Qt binaries, even though we deliberately remove it from the path. Am I missing something??

@jdtournier
Copy link
Member

Yes, that's odd. So it's the same config in both cases, but the build fails depending on the specific python version used? At this point, there should be no difference in the Qt version used, that's all set in the configure script.

Any chance you could post the build.log from the main install, showing how it built the files that are causing problems - e.g. ../mrtrix3/tmp/src/exec_version.o?

@dchristiaens
Copy link
Member Author

No, it's not the same config in both cases.

If I run ./configure using system python (2.7) and all dependencies installed through Homebrew, both the main MRtrix commands and the test module build without errors. (So I guess the title of this issue is no longer up to date.)

If I run ./configure with Anaconda python (3.9), the configure script still selects the Qt version installed through Homebrew, not the one installed through Anaconda, but fails with a Linker error on the last step of the ./configure script because the Homebrew-Qt is compiled for arm64 whereas the test program is being built for x86_64.

I uninstalled Anaconda and will look for other ways to manage my python3 setup. Frankly I'm sick of the whole 2-vs-3 debacle... I'll close this issue for now, but we may expect other build issues arising from Anaconda setups in future.

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

No branches or pull requests

2 participants