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

Compilation fails if using lld #63

Closed
TheRawMeatball opened this issue Jan 19, 2023 · 3 comments
Closed

Compilation fails if using lld #63

TheRawMeatball opened this issue Jan 19, 2023 · 3 comments

Comments

@TheRawMeatball
Copy link

In my ~/.cargo/config.toml, I have the following entry:

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-Clink-arg=-fuse-ld=lld"]

to improve link times and iteration speed. However, this seems to break linkme compilation, badly.

Here's a snippet from the error message during compilation:

  = note: ld.lld: error: undefined symbol: __start_linkme_BENCHMARKS                                                                                                                                                                                                                                                  
          >>> referenced by 29qlfu0bgl5pi1ii                                                                                                                                                                                                                                                                          
          >>>               /home/meatball/coding/linkme/target/debug/deps/example-d6ac051010cd24ec.29qlfu0bgl5pi1ii.rcgu.o:(example::BENCHMARKS::h84fb1b0801cd0cb3)                                                                                                                                                  
          >>> the encapsulation symbol needs to be retained under --gc-sections properly; consider -z nostart-stop-gc (see https://lld.llvm.org/ELF/start-stop-gc)                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                      
          ld.lld: error: undefined symbol: __stop_linkme_BENCHMARKS                                                                                                                                                                                                                                                   
          >>> referenced by 29qlfu0bgl5pi1ii                                                                                                                                                                                                                                                                          
          >>>               /home/meatball/coding/linkme/target/debug/deps/example-d6ac051010cd24ec.29qlfu0bgl5pi1ii.rcgu.o:(example::BENCHMARKS::h84fb1b0801cd0cb3)                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                      
          ld.lld: error: undefined symbol: __start_linkm2_BENCHMARKS                                                                                                                                                                                                                                                  
          >>> referenced by 29qlfu0bgl5pi1ii                                                                                                                                                                                                                                                                          
          >>>               /home/meatball/coding/linkme/target/debug/deps/example-d6ac051010cd24ec.29qlfu0bgl5pi1ii.rcgu.o:(example::BENCHMARKS::h84fb1b0801cd0cb3)                                                                                                                                                  
          >>> the encapsulation symbol needs to be retained under --gc-sections properly; consider -z nostart-stop-gc (see https://lld.llvm.org/ELF/start-stop-gc)                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                      
          ld.lld: error: undefined symbol: __stop_linkm2_BENCHMARKS                                                                                                                                                                                                                                                   
          >>> referenced by 29qlfu0bgl5pi1ii                                                                                                                                                                                                                                                                          
          >>>               /home/meatball/coding/linkme/target/debug/deps/example-d6ac051010cd24ec.29qlfu0bgl5pi1ii.rcgu.o:(example::BENCHMARKS::h84fb1b0801cd0cb3)                                                                                                                                                  
          clang-14: error: linker command failed with exit code 1 (use -v to see invocation)                                                                                                                                                                                                                          
@TheRawMeatball
Copy link
Author

TheRawMeatball commented Jan 19, 2023

Update: updating the config.toml entry to use the following seems to make all the tests compile and pass.

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-z", "-Clink-arg=nostart-stop-gc"]

Leaving the issue open as a request for this to be documented

@TheRawMeatball
Copy link
Author

Apparently this is a duplicate of #49.

@dtolnay dtolnay closed this as completed Jan 19, 2023
@dtolnay
Copy link
Owner

dtolnay commented Jan 19, 2023

I changed the title of #49 to remove the impression it's specific to FreeBSD.

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