diff --git a/src/test/shell/bazel/cc_integration_test.sh b/src/test/shell/bazel/cc_integration_test.sh index fb1a9bcce3ae18..1b557619150511 100755 --- a/src/test/shell/bazel/cc_integration_test.sh +++ b/src/test/shell/bazel/cc_integration_test.sh @@ -209,4 +209,52 @@ EOF "Second build failed, tree artifact was not invalidated." } +# This test tests that Bazel can produce dynamic libraries that have undefined +# symbols on Mac and Linux. Not sure it is a sane default to allow undefined +# symbols, but it's the default we had historically. This test creates +# an executable (main) that defines bar(), and a shared library (plugin) that +# calls bar(). When linking the libplugin.so, symbol 'bar' is undefined. +# +-----------------------------+ +----------------------------------+ +# | main | | libplugin.so | +# | | | | +# | main() { return foo(); } +---------> foo() { return bar() - 42; } | +# | | | + | +# | | | | | +# | bar() { return 42; } <------------------+ | +# | | | | +# +-----------------------------+ +----------------------------------+ +function test_undefined_dynamic_lookup() { + if is_windows; then + # Windows doesn't allow undefined symbols in shared libraries. + return 0 + fi + mkdir -p "dynamic_lookup" + cat > "dynamic_lookup/BUILD" < "dynamic_lookup/plugin.cc" < "dynamic_lookup/main.cc" <