Index: llvm/utils/gn/secondary/llvm/unittests/BUILD.gn =================================================================== --- llvm/utils/gn/secondary/llvm/unittests/BUILD.gn +++ llvm/utils/gn/secondary/llvm/unittests/BUILD.gn @@ -27,14 +27,10 @@ "ObjectYAML:ObjectYAMLTests", "OptRemarks:OptRemarksTests", "Option:OptionTests", - - # FIXME: Add. - #"Passes:PluginsTests", + "Passes:PluginsTests", "ProfileData:ProfileDataTests", "Support:SupportTests", - - # FIXME: Add. - #"Support/DynamicLibrary:DynamicLibraryTests", + "Support/DynamicLibrary:DynamicLibraryTests", "TextAPI:TextAPITests", "Transforms/IPO:IPOTests", "Transforms/Scalar:ScalarTests", Index: llvm/utils/gn/secondary/llvm/unittests/Passes/BUILD.gn =================================================================== --- /dev/null +++ llvm/utils/gn/secondary/llvm/unittests/Passes/BUILD.gn @@ -0,0 +1,52 @@ +import("//llvm/utils/unittest/unittest.gni") + +# Keyed off LLVM_ENABLE_PLUGINS in the CMake build, which is usually false +# on Windows and true elsewhere. +if (host_os != "win") { + loadable_module("TestPlugin") { + # Put plugin next to the unit test executable. + output_dir = target_out_dir + + sources = [ + "TestPlugin.cpp", + ] + + deps = [ + # TestPlugin doesn't want to link in any LLVM code, it just needs its + # headers. + "//llvm/include/llvm/IR:public_tablegen", + ] + + if (host_os == "linux") { + # The GN build currently doesn't globally pass -fPIC, but that's + # needed for building .so files on Linux. Just pass it manually + # for loadable_modules for now. + cflags = [ "-fPIC" ] + } + } +} + +unittest("PluginsTests") { + deps = [ + "//llvm/include/llvm/Config:config", + "//llvm/lib/IR", + "//llvm/lib/Passes", + "//llvm/lib/Support", + ] + sources = [ + "PluginsTest.cpp", + ] + + # If plugins are disabled, this test will disable itself at runtime. + # Otherwise, reconfiguring with plugins disabled will leave behind a stale + # executable. + if (host_os != "win") { + deps += [ ":TestPlugin" ] + defines = [ "LLVM_ENABLE_PLUGINS" ] + } + + if (host_os == "linux") { + # Corresponds to export_executable_symbols() in cmake. + ldflags = [ "-rdynamic" ] + } +} Index: llvm/utils/gn/secondary/llvm/unittests/Support/DynamicLibrary/BUILD.gn =================================================================== --- /dev/null +++ llvm/utils/gn/secondary/llvm/unittests/Support/DynamicLibrary/BUILD.gn @@ -0,0 +1,58 @@ +import("//llvm/utils/unittest/unittest.gni") + +# FIXME: If we add -Wl,-z,nodelete to the global ldflags, we need to remove +# it again for these tests (cf CMake). + +template("dynlib_add_module") { + # GN doesn't like if a template doesn't use invoker at all, even + # with not_needed(invoker), so pass in a dummy always-true bool. + assert(invoker.dummy) + + loadable_module(target_name) { + # Put plugin next to the unit test executable. + output_dir = target_out_dir + + sources = [ + "PipSqueak.cpp", + ] + + if (host_os == "linux") { + # The GN build currently doesn't globally pass -fPIC, but that's + # needed for building .so files on Linux. Just pass it manually + # for loadable_modules for now. + cflags = [ "-fPIC" ] + } + } +} + +dynlib_add_module("PipSqueak") { + dummy = true +} + +dynlib_add_module("SecondLib") { + dummy = true +} + +static_library("DynamicLibraryLib") { + sources = [ + "ExportedFuncs.cpp", + ] +} + +unittest("DynamicLibraryTests") { + deps = [ + ":DynamicLibraryLib", + ":PipSqueak", + ":SecondLib", + "//llvm/include/llvm/Config:config", + "//llvm/lib/Support", + ] + sources = [ + "DynamicLibraryTest.cpp", + ] + + if (host_os == "linux") { + # Corresponds to export_executable_symbols() in cmake. + ldflags = [ "-rdynamic" ] + } +}