From 53727b48fde1c275476e7531a0731bb1d9842dc5 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 14 Sep 2021 12:31:41 -0400 Subject: [PATCH] [gn build] Use lib_dirs instead of qualified path in libs for diaguids.lib Follow-up to D109708: Using lib_dirs means this will work with ancient gn binaries. Change the toolchain definitions to make lib_dirs have the right effect, and pull out lib_switch of each of the tools while here. This means we now do pass /LIBPATH: to link.exe, but since we invoke it directly and not through clang-cl, this doesn't actually require D109624. And since this is built in to GN, we don't need a config to push the flag to dependents. This is arguably a bit more idiomatic, and it doesn't require folks to update their GN binaries. No effective behavior change. Differential Revision: https://reviews.llvm.org/D109763 --- llvm/utils/gn/build/toolchain/BUILD.gn | 14 ++++++++------ llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn | 16 +++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn index 35fbb2d..0f33ee7 100644 --- a/llvm/utils/gn/build/toolchain/BUILD.gn +++ b/llvm/utils/gn/build/toolchain/BUILD.gn @@ -99,6 +99,10 @@ template("unix_toolchain") { "Update it, perhaps by running llvm/utils/gn/get.py") } + # Make these apply to all tools below. + lib_switch = "-l" + lib_dir_switch = "-L" + tool("solink") { outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" if (current_os == "ios" || current_os == "mac") { @@ -110,7 +114,6 @@ template("unix_toolchain") { } description = "SOLINK $outfile" outputs = [ outfile ] - lib_switch = "-l" output_prefix = "lib" default_output_dir = "{{root_out_dir}}/lib" } @@ -126,7 +129,6 @@ template("unix_toolchain") { } description = "SOLINK $outfile" outputs = [ outfile ] - lib_switch = "-l" default_output_dir = "{{root_out_dir}}/lib" } @@ -140,7 +142,6 @@ template("unix_toolchain") { } description = "LINK $outfile" outputs = [ outfile ] - lib_switch = "-l" # Setting this allows targets to override the default executable output by # setting output_dir. @@ -290,6 +291,10 @@ template("win_toolchain") { default_output_dir = "{{root_out_dir}}/lib" } + # Make these apply to all tools below. + lib_switch = "" + lib_dir_switch = "/LIBPATH:" + tool("solink") { outprefix = "{{output_dir}}/{{target_output_name}}" dllfile = "$outprefix{{output_extension}}" @@ -304,7 +309,6 @@ template("win_toolchain") { dllfile, libfile, ] - lib_switch = "" default_output_extension = ".dll" restat = true @@ -325,7 +329,6 @@ template("win_toolchain") { command = "$link /nologo /dll {{ldflags}} /out:$dllfile /pdb:$pdbfile {{inputs}} {{libs}} " description = "LINK_MODULE $dllfile" outputs = [ dllfile ] - lib_switch = "" runtime_outputs = outputs default_output_extension = ".dll" @@ -339,7 +342,6 @@ template("win_toolchain") { command = "$link /nologo {{ldflags}} /out:$outfile /pdb:$pdbfile {{inputs}} {{libs}}" description = "LINK $outfile" outputs = [ outfile ] - lib_switch = "" default_output_extension = ".exe" # Setting this allows targets to override the default executable output by diff --git a/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn index 07b34d4..040828f 100644 --- a/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/DebugInfo/PDB/BUILD.gn @@ -126,19 +126,17 @@ static_library("PDB") { dia_lib_path = "" if (sysroot != "") { - assert(gn_version >= 1937, - "Building with sysroot and DIA requires a newer GN. " + - "Run `python3 llvm\utils\gn\get.py` to update.") include_dirs = [ "$sysroot/DIA SDK/include" ] - dia_lib_path = "$sysroot/DIA SDK/lib/" # x86 .lib file is here. - if (current_cpu == "arm") { - dia_lib_path += "arm/" + dia_lib_path = "$sysroot/DIA SDK/lib" # x86 .lib file is here. + if (current_cpu == "/arm") { + dia_lib_path += "arm" } else if (current_cpu == "arm64") { - dia_lib_path += "arm64/" + dia_lib_path += "/arm64" } else if (current_cpu == "x64") { - dia_lib_path += "amd64/" + dia_lib_path += "/amd64" } + lib_dirs = [ dia_lib_path ] } - libs = [ "${dia_lib_path}diaguids.lib" ] + libs = [ "diaguids.lib" ] } } -- 2.7.4