This is an archive of the discontinued LLVM Phabricator instance.

[gn build] Add build files for unittests that load shared libraries
ClosedPublic

Authored by thakis on Jan 4 2019, 1:04 PM.

Details

Summary

This is slightly ugly for three reasons:

  • The shlib needs to go next to the binary to be found on all platforms, so the build files refer to target_out_dir
  • The explicit -fPIC flag needed on the shared lib side, and the -rdynamic flag needed on the host side, on Linux
  • Plugins that refer to LLVM code and assume that the host will resolve them don't work on Windows -- PluginsTests won't test anything on Windows (but DynamicLibraryTests will, since the dll here doesn't call LLVM code)

If we get lots more of these plugin / plugin host targets, it might make sense to add a template for them. But for now, these are the last ones we need. (We're at 6 plugin hosts, 2 of them tests, and at 6 shared libraries, 2 of them tests as well. clang is a plugin host by default in the CMake build but not (yet?) in the GN build.)

Diff Detail

Repository
rL LLVM

Event Timeline

thakis created this revision.Jan 4 2019, 1:04 PM
thakis updated this revision to Diff 180312.Jan 4 2019, 1:21 PM

remove needless static_library target

phosek accepted this revision.Jan 4 2019, 4:25 PM

LGTM

llvm/utils/gn/secondary/llvm/unittests/Support/DynamicLibrary/BUILD.gn
8 ↗(On Diff #180312)

Have you tried not_needed(invoker, "*")? We use that in our build.

This revision is now accepted and ready to land.Jan 4 2019, 4:25 PM
thakis marked an inline comment as done.Jan 4 2019, 5:38 PM
thakis added inline comments.
llvm/utils/gn/secondary/llvm/unittests/Support/DynamicLibrary/BUILD.gn
8 ↗(On Diff #180312)

That works, thanks! (Just not_needed(invoker) makes gn fail, but without any error message.)

This revision was automatically updated to reflect the committed changes.
thakis marked an inline comment as done.Jan 4 2019, 5:45 PM
thakis added inline comments.
llvm/utils/gn/secondary/llvm/unittests/Support/DynamicLibrary/BUILD.gn
8 ↗(On Diff #180312)