This is an archive of the discontinued LLVM Phabricator instance.

[Bazel] add linkopt to warn on unresolved symbols for llvm/lib/Support under FreeBSD
AbandonedPublic

Authored by wamuir on Sep 19 2021, 9:29 PM.

Details

Reviewers
None
Summary

PR adds -Wl,--warn-unresolved-symbols to linker flags for Bazel builds of llvm/lib/Support under FreeBSD. This avoids an error on an unresolved reference to environ. As far as I can tell, on FreeBSD, environ is defined as a common symbol in /usr/lib/crt1.o, and won't be resolved during linking. Ref extern char **environ in llvm/lib/Support/Unix/Program.inc.

Diff Detail

Event Timeline

wamuir created this revision.Sep 19 2021, 9:29 PM
wamuir requested review of this revision.Sep 19 2021, 9:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2021, 9:29 PM

Hmmm I rather suspect this isn't the right fix. Can you provide the error message you're hitting? I don't see any place that the CMake build has --warn-unresolved-symbols, so I suspect we're setting something wrong in the config.

Completely agree. This is a workaround and the issue appears to be specific to builds in Bazel/FreeBSD. For context, I'm encountering while building libtensorflow on FreeBSD 13.0.

I'll update shortly with the exact error message and additional details.

wamuir added a comment.EditedSep 21 2021, 8:08 AM

Closing. This is a build environment issue; error is ld: error: undefined symbol: environ and is the result of a default invocation of linker flag -z defs one of the tensorflow bazel build rules

wamuir abandoned this revision.Sep 21 2021, 8:12 AM