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

mold: fatal: unknown command line option: -flat_namespace #785

Open
georgemorgan opened this issue Oct 16, 2022 · 3 comments · May be fixed by #795
Open

mold: fatal: unknown command line option: -flat_namespace #785

georgemorgan opened this issue Oct 16, 2022 · 3 comments · May be fixed by #795

Comments

@georgemorgan
Copy link

When building Clang 16.0.0 on M1 Mac, using the latest version of mold, a fatal error is encountered: mold: fatal: unknown command line option: -flat_namespace.

Software:

    System Software Overview:

      System Version: macOS 12.6 (21G115)
      Kernel Version: Darwin 21.6.0

Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro18,3
      Chip: Apple M1 Pro
      Total Number of Cores: 10 (8 performance and 2 efficiency)
      Memory: 32 GB
mold 1.5.1 (341705e4a2593c4f64321130a2aedee9c46a66a3; compatible with GNU ld)
[961/5312] Linking CXX shared module lib/LLVMHello.dylib
FAILED: lib/LLVMHello.dylib
: && /opt/homebrew/opt/llvm/bin/clang++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -W
extra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi
 -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wn
o-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -arch arm64 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -bundle -Wl,-headerpad_max_install_n
ames --ld-path=/usr/local/bin/ld64.mold -L/opt/homebrew/opt/qt@5/lib -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/bison/lib -L
/opt/homebrew/opt/llvm/lib -Wl,-rpath,/opt/homebrew/opt/llvm/lib -L/usr/local/lib -L/opt/homebrew/lib -fuse-ld=/usr/local/bin/ld64.mold
 -L/opt/homebrew/opt/qt@5/lib -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/bison/lib -L/opt/homebrew/opt/llvm/lib -Wl,-rpath,/
opt/homebrew/opt/llvm/lib -L/usr/local/lib -L/opt/homebrew/lib -Wl,-flat_namespace -Wl,-undefined -Wl,suppress -Wl,--color-diagnostics
  -Wl,-dead_strip -Wl,-exported_symbols_list,"llvm-project/build/lib/Transforms/Hello/LLVMHello.exports"
-o lib/LLVMHello.dylib lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/Hello.cpp.o  -Wl,-rpath,@loader_path/../lib && :
mold: fatal: unknown command line option: -flat_namespace
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
[972/5312] Building CXX object lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/SLPVectorizer.cpp.o
ninja: build stopped: subcommand failed.
@carlocab
Copy link

To add to this: I believe this flag (-flat_namespace) along with support for -undefined dynamic_lookup (#706) and -undefined suppress are the only things required in order to successfully use mold as the linker without any errors when building clang.

That said, mold actually can already be used to link clang, if one ignores the linking errors from use of unsupported flags (e.g. ninja -k 0; you might also need to pass -DLLVM_BUILD_TESTS=OFF to CMake). I've already been able to build a working clang compiler that is itself able to build clang from doing this.

@rui314
Copy link
Owner

rui314 commented Oct 17, 2022

It's cool that we are already able to build clang with mold. We eventually need to support -flat_namespace, though I'm not sure why Clang pass that option. I can't think of a reason that clang needs that flag.

@carlocab
Copy link

Clang itself doesn't need it -- it is used to build some components of LLVM that are by-products of building clang. (Though I now can't recall if I issued ninja all or ninja clang, so it's possible that these by-products don't even need to be built at all.)

@carlocab carlocab linked a pull request Oct 19, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants