-
Notifications
You must be signed in to change notification settings - Fork 92
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
faq: adds section about linkers errors when using linkers incompatibl… #163
faq: adds section about linkers errors when using linkers incompatibl… #163
Conversation
Please, feel free to modify and/or rephrase anything as desired. This is just an initial suggestion trying to help people getting linking errors like the one described in the related issue. |
…e with compilers. related awslabs#151
bd9c85b
to
b58d862
Compare
LGTM! Thanks for the contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hbobenicio did you mix compilers when you encountered this error?
I've compiled with clang and gcc with LTO turned on and never had a problem.
Mixing compilers is not a supported use-case and generally very bad practice.
@@ -214,6 +214,8 @@ curl_easy_setopt(curl_handle, CURLOPT_CAINFO, "/etc/pki/tls/certs/ca-bundle.crt" | |||
- You can try hitting the non-TLS version of the endpoint if available. (Not Recommended). | |||
1. **No known conversion between `std::string` and `Aws::String`** | |||
- Either turn off custom memory management in the AWS C++ SDK or build it as a static library (`-DBUILD_SHARED_LIBS=OFF`) | |||
1. **I'm getting wierd linking errors like `/usr/bin/ld: /home/<...>bin/lib/libaws-lambda-runtime.a: error adding symbols: file format not recognized clang: error: linker command failed with exit code 1 (use -v to see invocation)`** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hbobenicio can you fix this typo wierd -> weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops :)
Nice catch!
@@ -214,6 +214,8 @@ curl_easy_setopt(curl_handle, CURLOPT_CAINFO, "/etc/pki/tls/certs/ca-bundle.crt" | |||
- You can try hitting the non-TLS version of the endpoint if available. (Not Recommended). | |||
1. **No known conversion between `std::string` and `Aws::String`** | |||
- Either turn off custom memory management in the AWS C++ SDK or build it as a static library (`-DBUILD_SHARED_LIBS=OFF`) | |||
1. **I'm getting wierd linking errors like `/usr/bin/ld: /home/<...>bin/lib/libaws-lambda-runtime.a: error adding symbols: file format not recognized clang: error: linker command failed with exit code 1 (use -v to see invocation)`** | |||
- By default this project enables _link-time optimization (LTO)_ (configurable with `ENABLE_LTO` _cmake_ option). This tells compilers to delay optimizations until the linking phase. For some compilers (like _clang_) this means that each compilation unit should be compiled down only to intermediate representations (_e.g._ _clang_ uses _LLVM IR_) instead of directly to native object files. As a side-effect, library archives (like _aws-lambda-runtime_) would also contain only _IR_ code. This may result in linker errors like the above if you use a linker incompatible with the _IR_ code generated by your compiler (e.g. _GNU ld_ linker doesn't support _LLVM IR_). In order for the linking step to succeed with _LTO_ you must either use an appropriate linker with something like `-DCMAKE_CXX_FLAGS="-fuse-ld=lld"` (_GNU ld_ for _gcc_ and _lld_ for _clang_ are known to work) or disable _LTO_ (`-DENABLE_LTO=OFF`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this means that each compilation unit should be compiled down only to intermediate representations (e.g. clang uses LLVM IR) instead of directly to native object files.
Moreover, I'd rather avoid making such claims on how the linker/compiler works because:
- I'm not an expert so I really don't know.
- If that information gets outdated in the future, we don't end up with stale or wrong claims.
I think it's better to suggest turning off LTO and keep it succinct. That's assuming the problem exists, which I'm not yet sure is that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agreeded. You're right. I'm gonna try to rephrase that tomorrow. This became too assertive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Also, it would be nice if you can provide me with steps on triggering this problem. I can't reproduce it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Working on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. The dockerfile is on the issue #151
Not actually.
Yeah... I got this compiling with gcc/LTO/ld and clang/LTO/lld too.
Sure. C ABI's is actually pretty standard and portable, but sometimes it can get really messy. |
I don't recall having to change the linker when I compiled with clang and gcc. I'm still skeptical. Maybe @bmoffatt can try to reproduce it. Unfortunately, I don't have access to a Linux box/container right now. However, seeing this:
tells me that the runtime is built as a static-library, so no linking step was involved. The linking happened later in your application. And either your toolchain is somehow tangled up, or if it is indeed a problem that @bmoffatt can reproduce then we should turn off LTO when |
Issue #, if available: #151
Description of changes:
Adds an entry to the FAQ & Troubleshooting section about linking errors when using a linker incompatible with the IR used by the compiler, when
ENABLE_LTO=ON
(which is the default option).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.