-
Notifications
You must be signed in to change notification settings - Fork 102
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
Undefined symbol when linking to a shared library produced by native.rule code generation #230
Comments
bazel-io
pushed a commit
to bazel-io/bazel
that referenced
this issue
Aug 27, 2024
When linking a nodeps dynamic library that contains object files produced from tree artifact sources, the library may not contain any references to the symbols in those files. In this case, when wrapping the files in `--start-lib/--end-lib`, they may end up being dropped by the linker, which results in missing symbols compared to a build with `--dynamic_mode=off`. This is fixed by not wrapping object files into `--start-lib/--end-lib` for the nodeps dynamic library link action. Fixes bazelbuild/rules_cc#230 Closes bazelbuild#23084. PiperOrigin-RevId: 667945814 Change-Id: Iec148ad1b86626bb5263fecc9b98b0db89f81ad6
github-merge-queue bot
pushed a commit
to bazelbuild/bazel
that referenced
this issue
Sep 23, 2024
…s libraries (#23437) When linking a nodeps dynamic library that contains object files produced from tree artifact sources, the library may not contain any references to the symbols in those files. In this case, when wrapping the files in `--start-lib/--end-lib`, they may end up being dropped by the linker, which results in missing symbols compared to a build with `--dynamic_mode=off`. This is fixed by not wrapping object files into `--start-lib/--end-lib` for the nodeps dynamic library link action. Fixes bazelbuild/rules_cc#230 Closes #23084. PiperOrigin-RevId: 667945814 Change-Id: Iec148ad1b86626bb5263fecc9b98b0db89f81ad6 Commit 164ffa5 Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
github-merge-queue bot
pushed a commit
to bazelbuild/bazel
that referenced
this issue
Sep 23, 2024
…s libraries (#23437) When linking a nodeps dynamic library that contains object files produced from tree artifact sources, the library may not contain any references to the symbols in those files. In this case, when wrapping the files in `--start-lib/--end-lib`, they may end up being dropped by the linker, which results in missing symbols compared to a build with `--dynamic_mode=off`. This is fixed by not wrapping object files into `--start-lib/--end-lib` for the nodeps dynamic library link action. Fixes bazelbuild/rules_cc#230 Closes #23084. PiperOrigin-RevId: 667945814 Change-Id: Iec148ad1b86626bb5263fecc9b98b0db89f81ad6 Commit 164ffa5 Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
github-merge-queue bot
pushed a commit
to bazelbuild/bazel
that referenced
this issue
Sep 23, 2024
…s libraries (#23437) When linking a nodeps dynamic library that contains object files produced from tree artifact sources, the library may not contain any references to the symbols in those files. In this case, when wrapping the files in `--start-lib/--end-lib`, they may end up being dropped by the linker, which results in missing symbols compared to a build with `--dynamic_mode=off`. This is fixed by not wrapping object files into `--start-lib/--end-lib` for the nodeps dynamic library link action. Fixes bazelbuild/rules_cc#230 Closes #23084. PiperOrigin-RevId: 667945814 Change-Id: Iec148ad1b86626bb5263fecc9b98b0db89f81ad6 Commit 164ffa5 Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
github-merge-queue bot
pushed a commit
to bazelbuild/bazel
that referenced
this issue
Sep 24, 2024
…s libraries (#23437) When linking a nodeps dynamic library that contains object files produced from tree artifact sources, the library may not contain any references to the symbols in those files. In this case, when wrapping the files in `--start-lib/--end-lib`, they may end up being dropped by the linker, which results in missing symbols compared to a build with `--dynamic_mode=off`. This is fixed by not wrapping object files into `--start-lib/--end-lib` for the nodeps dynamic library link action. Fixes bazelbuild/rules_cc#230 Closes #23084. PiperOrigin-RevId: 667945814 Change-Id: Iec148ad1b86626bb5263fecc9b98b0db89f81ad6 Commit 164ffa5 Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
copybara-service bot
pushed a commit
that referenced
this issue
Jan 7, 2025
Imported changes from Github: - e278ee35e5ab56757bcd5ca3f10cab4822da1f1e Prepare release 0.7.2 (#258) by Alexandre Rostovtsev <arostovtsev@google.com> - bee95475e35903ac166766bc3df146d2acf4cbdb Remove apple_basic_test - we should not be accessing appl... by Alexandre Rostovtsev <arostovtsev@google.com> - aefab4cf8d6f46f1de97ae9e57fed9ba0648c3f1 fix: add missing proto_library load to support Bazel 8 (#... by Richard Levasseur <richardlev@gmail.com> - 91e429d9e2e959893c1ce2f81c35806b3a2daf8c Replace AppleDynamicFramework in test/testdata/apple_basi... by Philip Zembrod <pzembrod@gmail.com> - 46fd77a446f00faddedd0467ce993b462fba3c8a Delete usages/tests of the builtin bazel java symbols (#2... by hvadehra <hvadehra@gmail.com> - 2ac0981b7c35ff46cf66cc92467c37411c7bfacc Update proto and prepare release 0.7.1 (#239) by Alexandre Rostovtsev <arostovtsev@google.com> - 03eb7ce460e3aa54fee1f4fac8fa6bfc3d7294f2 Fix CI since --enable_workspace is now disabled by defaul... by Alexandre Rostovtsev <arostovtsev@google.com> - 2100c63ca234836bd600800587076860a6973918 Merge user-defined tags with default tags in stardoc macr... by yashathwani <145871056+yashathwani@users.noreply.github.com> - db47c15e8d342c5e5b95d81554d7f901ba062c2e Revert most of #237 and #238 (#243) by Alexandre Rostovtsev <arostovtsev@google.com> - 0ac26cd45b01011ffc172bd2054f07e9df1efbf2 Skip Bazel 7.2 tests in downstream pipeline (#244) by Alexandre Rostovtsev <arostovtsev@google.com> - da374a508b5a5f82e1e00f94889f04f9f86ca1fe Fix internal linter warnings (#235) by Alexandre Rostovtsev <arostovtsev@google.com> - c026daeee09fb072a02be87dfc87ea60d157e770 Improve incompatible flag testing (#238) by Alexandre Rostovtsev <arostovtsev@google.com> - 7f0601624ceb55c84690ba9fc86a097a4c7cf6b8 Make Stardoc work with --incompatible_enable_proto_toolch... by lberki <lberki@users.noreply.github.com> - 00cc953512de26265c2c9b86947b5b13f338d707 Prepare release 0.7.0 (#233) by Alexandre Rostovtsev <arostovtsev@google.com> - 1be7db63c28825a147670fe68d223633e37c8141 Do not emit rules_pkg dep in distro tarball's MODULE.baze... by Alexandre Rostovtsev <arostovtsev@google.com> - 92a4819c07f0985aba3746a5d89b81b6a4adf194 Respect --stamp and --nostamp flags for stamping (#234) by Alexandre Rostovtsev <arostovtsev@google.com> - 018dee5bd296d81fa3f1eff3a08512d190ff7181 Include `load` in summaries (#216) by Fabian Meumertzheim <fabian@meumertzhe.im> - aba1a01295094e9df40fc94e355f54e7e98dcd33 Update test regeneration script to support multiple Bazel... by Alexandre Rostovtsev <arostovtsev@google.com> - f39ed53f56f2de895b2f1891fa166b2b3b0e3fe7 Render *args / * / **kwargs properly in function summary ... by Alexandre Rostovtsev <arostovtsev@google.com> - f40819fd48193987f8cd22d724fbbab2a7aaf322 Refactor param rendering in summary line (#230) by Alexandre Rostovtsev <arostovtsev@google.com> - 4644386b36253da4436bb961ed1f5fbcc8c15101 proto_format_test requires Bazel 7.1, and may break with ... by Alexandre Rostovtsev <arostovtsev@google.com> - 666b7ba7124b9af9c531c6c5f2013f69b27ea144 Render documentation for provider `init` callbacks (#224) by Alexandre Rostovtsev <arostovtsev@google.com> ... and update copybara configs and tests. BEGIN_PUBLIC Regenerate Starlark docs using Stardoc 0.7.2. END_PUBLIC PiperOrigin-RevId: 713040596 Change-Id: Id84f0010b5c873041c30880d7b47ac6e5eaa5c74
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description of the problem / feature request:
When using
native.rule
to generate some C++ code I get undefined reference error when linking tests to shared library which is using that generated code.Generated file names are not known beforehand, and the output is collected via
declare_directory()
.The generated shared library contains no symbols from object files (if you inspect it via
nm
), and linker command line shows that object files are linked inside--start-lib
and--end-lib
block.Conversely, if you generate same sources via
genrule
with explicit output file names, everything works fine, object files are not surrounded by start/end-lib and symbols are present in generated shared libraryBugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
See example.tar.gz file for minimal example.
You can build it using command line
bazel build //:testCodegen --//:impl=<1 or 2>
In case of
sources are generated via native.rule and linker displays undefined symbol hello_world() error
In case of
sources are generated via genrule and test compiles just fine
What operating system are you running Bazel on?
Debian 11 (Bullseye), amd64
What's the output of
bazel info release
?release 7.0.0
What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?
Default version
What Bazel options do you use to trigger the issue? What C++ toolchain do you use?
reproducible with clang 17 and Clang 13 with lld linker
Have you found anything relevant by searching the web?
Reached slack channel and was advised to open a ticket
Any other information, logs, or outputs that you want to share?
See attachment
The text was updated successfully, but these errors were encountered: