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

macOS x64 clang build failing #19591

Open
marbre opened this issue Jan 2, 2025 · 8 comments
Open

macOS x64 clang build failing #19591

marbre opened this issue Jan 2, 2025 · 8 comments
Assignees
Labels
bindings/python Python wrapping IREE's C API bug 🐞 Something isn't working infrastructure Relating to build systems, CI, or testing platform/macos 🍎 MacOS-specific build, execution, benchmarking, and deployment

Comments

@marbre
Copy link
Member

marbre commented Jan 2, 2025

The CI - macOS x64 clang workflow started failing when scheduled for commit f1e1866 (build log https://github.com/iree-org/iree/actions/runs/12514308966) when linking compiler/bindings/python/iree/compiler/_mlir_libs/_mlir.cpython-311-darwin.so:

[7968/8273] Linking CXX shared module compiler/bindings/python/iree/compiler/_mlir_libs/_mlir.cpython-311-darwin.so
FAILED: compiler/bindings/python/iree/compiler/_mlir_libs/_mlir.cpython-311-darwin.so 
: && /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O2 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.7 -bundle -Wl,-headerpad_max_install_names -Wl,@/Users/runner/work/iree/iree/build-macos/_deps/nanobind-src/cmake/darwin-ld-cpython.sym -lm -o compiler/bindings/python/iree/compiler/_mlir_libs/_mlir.cpython-311-darwin.so compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/MainModule.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRAffine.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRAttributes.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRCore.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRInterfaces.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRModule.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRTypes.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/Pass.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/Rewrite.cpp.o  -Wl,-rpath,@loader_path -Wl,-rpath,/Users/runner/work/iree/iree/build-macos/lib  llvm-project/lib/libnanobind-static.a  lib/libIREECompiler.dylib  llvm-project/lib/libLLVMSupport.a  -lm  llvm-project/lib/libLLVMDemangle.a && :
ld: warning: ignoring duplicate libraries: '-lm'
ld: Undefined symbols:
  _PyClassMethod_New, referenced from:
      mlir::python::populateIRCore(nanobind::module_&) in IRCore.cpp.o
      nanobind::object classmethod<nanobind::object (*)(nanobind::object const&, std::__1::optional<nanobind::list>, nanobind::list, std::__1::optional<nanobind::dict>, std::__1::optional<std::__1::vector<mlir::python::PyBlock*, std::__1::allocator<mlir::python::PyBlock*>>>, std::__1::optional<int>, mlir::python::DefaultingPyLocation, nanobind::object const&), nanobind::arg, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, char const*>(nanobind::object (*)(nanobind::object const&, std::__1::optional<nanobind::list>, nanobind::list, std::__1::optional<nanobind::dict>, std::__1::optional<std::__1::vector<mlir::python::PyBlock*, std::__1::allocator<mlir::python::PyBlock*>>>, std::__1::optional<int>, mlir::python::DefaultingPyLocation, nanobind::object const&), nanobind::arg, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, char const*) in IRCore.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The integrate commit f1e1866 updates LLVM to llvm/llvm-project@b135922. This includes llvm/llvm-project@b56d1ec with ports the Python core code to nanobind. The build only fails for macOS but passes for other platforms.

Till now, IREE's compiler bindings are build with pybind11. Porting IREE's compiler bindings from pybind11 to nanobind (PR #19580), the following (additional) targets fail for macOS which reference _PyClassMethod_New:

  • IREECompilerDialectsModule.cpp.o
  • DialectGPU.cpp.o
  • IRCore.cpp.o
  • DialectPDL.cpp.o
  • DialectLLVM.cpp.o
  • DialectTransform.cpp.o

Upstream macOS is several builds seem to pass, see for example https://github.com/makslevental/mlir-wheels/actions/runs/12565899455 or https://github.com/llvm/eudsl/actions/runs/12576273972/job/35052215749.


Errors (https://github.com/iree-org/iree/actions/runs/12583361482/job/35070746468) for PR #19580:

[7969/8276] Linking CXX shared module compiler/bindings/python/iree/compiler/_mlir_libs/_ireeCompilerDialects.cpython-311-darwin.so
FAILED: compiler/bindings/python/iree/compiler/_mlir_libs/_ireeCompilerDialects.cpython-311-darwin.so 
: && /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O2 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.7 -bundle -Wl,-headerpad_max_install_names -Wl,@/Users/runner/work/iree/iree/build-macos/_deps/nanobind-src/cmake/darwin-ld-cpython.sym -lm -o compiler/bindings/python/iree/compiler/_mlir_libs/_ireeCompilerDialects.cpython-311-darwin.so compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._ireeCompilerDialects.dso.dir/IREECompilerDialectsModule.cpp.o  -Wl,-rpath,@loader_path -Wl,-rpath,/Users/runner/work/iree/iree/build-macos/lib  llvm-project/lib/libnanobind-static.a  lib/libIREECompiler.dylib  llvm-project/lib/libLLVMSupport.a  -lm  llvm-project/lib/libLLVMDemangle.a && :
ld: warning: ignoring duplicate libraries: '-lm'
ld: Undefined symbols:
  _PyClassMethod_New, referenced from:
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      nanobind_init__ireeCompilerDialects(nanobind::module_&) in IREECompilerDialectsModule.cpp.o
      ...
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[7971/8276] Linking CXX shared module compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsGPU.cpython-311-darwin.so
FAILED: compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsGPU.cpython-311-darwin.so 
: && /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O2 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.7 -bundle -Wl,-headerpad_max_install_names -Wl,@/Users/runner/work/iree/iree/build-macos/_deps/nanobind-src/cmake/darwin-ld-cpython.sym -lm -o compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsGPU.cpython-311-darwin.so compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlirDialectsGPU.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/DialectGPU.cpp.o  -Wl,-rpath,@loader_path -Wl,-rpath,/Users/runner/work/iree/iree/build-macos/lib  llvm-project/lib/libnanobind-static.a  lib/libIREECompiler.dylib  llvm-project/lib/libLLVMSupport.a  -lm  llvm-project/lib/libLLVMDemangle.a && :
ld: warning: ignoring duplicate libraries: '-lm'
ld: Undefined symbols:
  _PyClassMethod_New, referenced from:
      _PyInit__mlirDialectsGPU in DialectGPU.cpp.o
      _PyInit__mlirDialectsGPU in DialectGPU.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[7973/8276] Linking CXX shared module compiler/bindings/python/iree/compiler/_mlir_libs/_mlir.cpython-311-darwin.so
FAILED: compiler/bindings/python/iree/compiler/_mlir_libs/_mlir.cpython-311-darwin.so 
: && /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O2 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.7 -bundle -Wl,-headerpad_max_install_names -Wl,@/Users/runner/work/iree/iree/build-macos/_deps/nanobind-src/cmake/darwin-ld-cpython.sym -lm -o compiler/bindings/python/iree/compiler/_mlir_libs/_mlir.cpython-311-darwin.so compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/MainModule.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRAffine.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRAttributes.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRCore.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRInterfaces.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRModule.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/IRTypes.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/Pass.cpp.o compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlir.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/Rewrite.cpp.o  -Wl,-rpath,@loader_path -Wl,-rpath,/Users/runner/work/iree/iree/build-macos/lib  llvm-project/lib/libnanobind-static.a  lib/libIREECompiler.dylib  llvm-project/lib/libLLVMSupport.a  -lm  llvm-project/lib/libLLVMDemangle.a && :
ld: warning: ignoring duplicate libraries: '-lm'
ld: Undefined symbols:
  _PyClassMethod_New, referenced from:
      mlir::python::populateIRCore(nanobind::module_&) in IRCore.cpp.o
      nanobind::object classmethod<nanobind::object (*)(nanobind::object const&, std::__1::optional<nanobind::list>, nanobind::list, std::__1::optional<nanobind::dict>, std::__1::optional<std::__1::vector<mlir::python::PyBlock*, std::__1::allocator<mlir::python::PyBlock*>>>, std::__1::optional<int>, mlir::python::DefaultingPyLocation, nanobind::object const&), nanobind::arg, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, char const*>(nanobind::object (*)(nanobind::object const&, std::__1::optional<nanobind::list>, nanobind::list, std::__1::optional<nanobind::dict>, std::__1::optional<std::__1::vector<mlir::python::PyBlock*, std::__1::allocator<mlir::python::PyBlock*>>>, std::__1::optional<int>, mlir::python::DefaultingPyLocation, nanobind::object const&), nanobind::arg, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, nanobind::arg_v, char const*) in IRCore.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[7977/8276] Linking CXX shared module compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsLLVM.cpython-311-darwin.so
FAILED: compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsLLVM.cpython-311-darwin.so 
: && /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O2 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.7 -bundle -Wl,-headerpad_max_install_names -Wl,@/Users/runner/work/iree/iree/build-macos/_deps/nanobind-src/cmake/darwin-ld-cpython.sym -lm -o compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsLLVM.cpython-311-darwin.so compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlirDialectsLLVM.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/DialectLLVM.cpp.o  -Wl,-rpath,@loader_path -Wl,-rpath,/Users/runner/work/iree/iree/build-macos/lib  llvm-project/lib/libnanobind-static.a  lib/libIREECompiler.dylib  llvm-project/lib/libLLVMSupport.a  -lm  llvm-project/lib/libLLVMDemangle.a && :
ld: warning: ignoring duplicate libraries: '-lm'
ld: Undefined symbols:
  _PyClassMethod_New, referenced from:
      populateDialectLLVMSubmodule(nanobind::module_ const&) in DialectLLVM.cpp.o
      populateDialectLLVMSubmodule(nanobind::module_ const&) in DialectLLVM.cpp.o
      populateDialectLLVMSubmodule(nanobind::module_ const&) in DialectLLVM.cpp.o
      populateDialectLLVMSubmodule(nanobind::module_ const&) in DialectLLVM.cpp.o
      populateDialectLLVMSubmodule(nanobind::module_ const&) in DialectLLVM.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[7980/8276] Linking CXX shared module compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsPDL.cpython-311-darwin.so
FAILED: compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsPDL.cpython-311-darwin.so 
: && /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O2 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.7 -bundle -Wl,-headerpad_max_install_names -Wl,@/Users/runner/work/iree/iree/build-macos/_deps/nanobind-src/cmake/darwin-ld-cpython.sym -lm -o compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsPDL.cpython-311-darwin.so compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlirDialectsPDL.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/DialectPDL.cpp.o  -Wl,-rpath,@loader_path -Wl,-rpath,/Users/runner/work/iree/iree/build-macos/lib  llvm-project/lib/libnanobind-static.a  lib/libIREECompiler.dylib  llvm-project/lib/libLLVMSupport.a  -lm  llvm-project/lib/libLLVMDemangle.a && :
ld: warning: ignoring duplicate libraries: '-lm'
ld: Undefined symbols:
  _PyClassMethod_New, referenced from:
      populateDialectPDLSubmodule(nanobind::module_ const&) in DialectPDL.cpp.o
      populateDialectPDLSubmodule(nanobind::module_ const&) in DialectPDL.cpp.o
      populateDialectPDLSubmodule(nanobind::module_ const&) in DialectPDL.cpp.o
      populateDialectPDLSubmodule(nanobind::module_ const&) in DialectPDL.cpp.o
      populateDialectPDLSubmodule(nanobind::module_ const&) in DialectPDL.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[7983/8276] Linking CXX shared module compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsTransform.cpython-311-darwin.so
FAILED: compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsTransform.cpython-311-darwin.so 
: && /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O2 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=13.7 -bundle -Wl,-headerpad_max_install_names -Wl,@/Users/runner/work/iree/iree/build-macos/_deps/nanobind-src/cmake/darwin-ld-cpython.sym -lm -o compiler/bindings/python/iree/compiler/_mlir_libs/_mlirDialectsTransform.cpython-311-darwin.so compiler/bindings/python/CMakeFiles/IREECompilerPythonModules.extension._mlirDialectsTransform.dso.dir/__/__/__/third_party/llvm-project/mlir/lib/Bindings/Python/DialectTransform.cpp.o  -Wl,-rpath,@loader_path -Wl,-rpath,/Users/runner/work/iree/iree/build-macos/lib  llvm-project/lib/libnanobind-static.a  lib/libIREECompiler.dylib  llvm-project/lib/libLLVMSupport.a  -lm  llvm-project/lib/libLLVMDemangle.a && :
ld: warning: ignoring duplicate libraries: '-lm'
ld: Undefined symbols:
  _PyClassMethod_New, referenced from:
      populateDialectTransformSubmodule(nanobind::module_ const&) in DialectTransform.cpp.o
      populateDialectTransformSubmodule(nanobind::module_ const&) in DialectTransform.cpp.o
      populateDialectTransformSubmodule(nanobind::module_ const&) in DialectTransform.cpp.o
      populateDialectTransformSubmodule(nanobind::module_ const&) in DialectTransform.cpp.o
      populateDialectTransformSubmodule(nanobind::module_ const&) in DialectTransform.cpp.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@marbre marbre added the bindings/python Python wrapping IREE's C API label Jan 2, 2025
@ScottTodd ScottTodd added bug 🐞 Something isn't working infrastructure Relating to build systems, CI, or testing platform/macos 🍎 MacOS-specific build, execution, benchmarking, and deployment labels Jan 2, 2025
marbre added a commit to marbre/iree that referenced this issue Jan 2, 2025
With CMake 3.18+ (the minimum version set for IREE is 3.21), it should
be sufficient to search for `Development.Module` instead of
`Development`. We therefore skip searching for the latter as this might
be the root for issue with the current macOS builds (see iree-org#19591).
marbre added a commit that referenced this issue Jan 2, 2025
With CMake 3.18+ (the minimum version set for IREE is 3.21), it should
be sufficient to search for `Development.Module` instead of
`Development`. We therefore skip searching for the latter as this might
be the root for issue with the current macOS builds (see #19591).
@marbre
Copy link
Member Author

marbre commented Jan 3, 2025

Dropping

find_package(Python3 3.9 COMPONENTS Interpreter Development NumPy)

does not resolve the problem. Furthermore,
set(MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES ON CACHE BOOL "" FORCE)

is already set if building with a bundled LLVM.

@makslevental
Copy link
Contributor

makslevental commented Jan 3, 2025

I figured it out but I don't know what the right solution is yet; TL;DR we are in fact missing a symbol.

Upstream has these pure_subclass things which use PyClassMethod_New but nanobind doesn't and doesn't know about them in its linker flags file. So a hack/patch fix (which works) is adding -U PyClassMethod_New to that nanobind file.

The reason this doesn't fail upstream is because HandleLLVMOptions just YOLOs all of the symbols on Mac (i.e. does -undefined dynamic_lookup) and somewhere IREE undoes that YOLO (no clue where).

There are couple of fixes:

  1. fix in upstream to add target_link_options(-U PyClassMethod_New) to nanobind extensions;
  2. change upstream to use the same cpython functions that nanobind uses (not sure which);
  3. change IREE to YOLO just like upstream HandleLLVMOptions;
  4. change IREE to do have the -U PyClassMethod_New linker flag.

I suppose it's 4 now to unblock and then 1 upstream.

cc @jpienaar @stellaraccident @yzhang93

@makslevental makslevental self-assigned this Jan 3, 2025
@ScottTodd
Copy link
Member

The reason this doesn't fail upstream is because HandleLLVMOptions just YOLOs all of the symbols on Mac (i.e. does -undefined dynamic_lookup) and somewhere IREE undoes that YOLO (no clue where).

IREE doesn't include HandleLLVMOptions. There's too much in there for a downstream with different usage models to unconditionally use in our experience. IREE has these files instead:

@marbre
Copy link
Member Author

marbre commented Jan 3, 2025

I suppose it's 4 now to unblock and then 1 upstream.

Thanks Maks! I would vote for 4 until we get possibly get option 1 or 2 later.

@stellaraccident
Copy link
Collaborator

Ugh. 4 is fine for now. Thanks for the triage

@stellaraccident
Copy link
Collaborator

I'm also fine with #3. It is pretty obnoxious when the build passes but all tests fail on a missing symbol, but whatever works.

One thing that other projects do: use the nanobind stub generator as part of the build. That has the byproduct of loading the built library, causing linkage issues to be surfaced at build time.

That's probably the most hands off was to do it that will require the least intervention over time.

@marbre
Copy link
Member Author

marbre commented Jan 6, 2025

Just cherry-picking and applying the fix on top of your current LLVM integrate (branch iree-org/llvm-project: integrate/20250103+nanobind-fix) does not make the CI pass (Run 12630160413). Reverting the nanobind related upstream changes does (PR #19605, branch iree-org/llvm-project: integrate/20250103+nanobind-reverts, Run 12621186146). Thus the upstream fix either relies on some intermediate patched which I missed to cherry-pick or this might need more work.

ScottTodd added a commit to iree-org/iree-turbine that referenced this issue Jan 6, 2025
Similar to #354, we're
approaching our 3.1.0 release across all IREE packages
(iree-org/iree#19192), so testing closer to
HEAD.

Changes needed:

* Update `FlatSymbolRefAttr` usage, similar to
nod-ai/shark-ai#732
* Allow the "Test Build Release" workflow to skip failed experimental
release downloads while IREE's macOS compiler release builds are broken
(iree-org/iree#19591)

Commit range:
iree-org/iree@iree-3.1.0rc20241220...iree-3.1.0rc20250103
marbre added a commit that referenced this issue Jan 6, 2025
Adds nanobind reverts on top of #19600 to allow the macOS build to pass
(see #19591).
@makslevental
Copy link
Contributor

Just a heads up (because I've been pulling my hair out for hours somewhere else about this; -Wl,-U is not correct for linux:

-DCMAKE_MODULE_LINKER_FLAGS="-Wl,-U -Wl,_PyClassMethod_New"

and what will happen is you'll get the weirdest

note: /usr/bin/ld: -r and -shared may not be used together

because the correct flag on linux is -Wl,-u. Quite infuriatingly the u/U flags mean basically opposite (or something) things on the two platforms:

Infuriatingly they mean the exact opposite things on the platforms:

mac

lld

-u symbol_name
             Specified that symbol symbol_name must be defined for the link to succeed.  
             This is useful to force selected functions to be loaded from a static library.

-U symbol_name
             Specified that it is ok for symbol_name to have no definition.  
             With -two_levelnamespace, the resulting symbol will be marked dynamic_lookup which means dyld will search all loaded images.

linux

lld

  --undefined-glob=<pattern>
                          Force undefined symbol during linking
  --undefined-version     Allow unused version in version script (disabled by default)
  --undefined=<symbol>    Force undefined symbol during linking
  -u <value>              Alias for --undefined

ld

  -Ur                         Build global constructor/destructor tables
  -u SYMBOL, --undefined SYMBOL
                              Start with undefined reference to SYMBOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings/python Python wrapping IREE's C API bug 🐞 Something isn't working infrastructure Relating to build systems, CI, or testing platform/macos 🍎 MacOS-specific build, execution, benchmarking, and deployment
Projects
None yet
Development

No branches or pull requests

4 participants