[llvm] [bazel] Rework liblldb (PR #91549)
Keith Smiley via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 09:42:02 PDT 2024
================
@@ -728,37 +728,57 @@ cc_library(
],
)
-cc_library(
- name = "liblldb.static",
- deps = [
- ":API",
- ":Interpreter",
- ],
+genrule(
+ name = "gen_exports_file_linux",
+ srcs = ["//lldb:source/API/liblldb-private.exports"],
+ outs = ["exports_linux.txt"],
+ cmd = """
+cat > $(OUTS) <<EOF
+{
+ global:
+ $$(sed 's/$$/;/g' $(SRCS))
+};
+EOF
+""",
)
-cc_shared_library(
- name = "liblldb",
- # TODO: Remove once fixed https://github.com/bazelbuild/bazel/issues/21893
+genrule(
+ name = "gen_exports_file_macos",
+ srcs = ["//lldb:source/API/liblldb-private.exports"],
+ outs = ["exports_macos.txt"],
+ cmd = "sed 's/^/_/g' $(SRCS) > $(OUTS)",
+)
+
+cc_binary(
+ name = "lldb{}".format(PACKAGE_VERSION),
additional_linker_inputs = select({
+ "@platforms//os:linux": [
+ ":gen_exports_file_linux",
+ ],
"@platforms//os:macos": [
- ":HostMacOSXObjCXX",
- "//lldb/source/Plugins:PluginPlatformMacOSXObjCXX",
+ ":gen_exports_file_macos",
],
"//conditions:default": [],
}),
- shared_lib_name = select({
- "@platforms//os:macos": "liblldb{}.dylib".format(PACKAGE_VERSION),
- "@platforms//os:linux": "liblldb{}.so".format(PACKAGE_VERSION),
- }),
- # TODO: Remove once fixed https://github.com/bazelbuild/bazel/issues/21893
- user_link_flags = select({
+ linkopts = select({
+ "@platforms//os:linux": [
+ "-Wl,--export-dynamic-symbol-list=$(location :gen_exports_file_linux)",
+ ],
"@platforms//os:macos": [
- "$(location :HostMacOSXObjCXX)",
- "$(location //lldb/source/Plugins:PluginPlatformMacOSXObjCXX)",
+ "-Wl,-exported_symbols_list,$(location :gen_exports_file_macos)",
],
"//conditions:default": [],
}),
- deps = [":liblldb.static"],
+ linkshared = True,
----------------
keith wrote:
yea there's some interesting stuff in this old API! emit is definitely a nicer API!
https://github.com/llvm/llvm-project/pull/91549
More information about the llvm-commits
mailing list