diff --git a/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S index e98893c7ef8b8..d6fa51638da39 100644 --- a/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S +++ b/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S @@ -16,15 +16,17 @@ #define _CET_ENDBR #endif -#ifdef __APPLE__ -#define HIDDEN .private_extern +#if defined(__APPLE__) +#define HIDDEN(symbol) .private_extern symbol +#elif defined(__ELF__) +#define HIDDEN(symbol) .hidden symbol #else -#define HIDDEN .hidden +#define HIDDEN(symbol) #endif .intel_syntax noprefix -HIDDEN _blake3_hash_many_avx2 -HIDDEN blake3_hash_many_avx2 +HIDDEN(_blake3_hash_many_avx2) +HIDDEN(blake3_hash_many_avx2) .global _blake3_hash_many_avx2 .global blake3_hash_many_avx2 #ifdef __APPLE__ diff --git a/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S index b4b14946de10e..cf2c88329af5c 100644 --- a/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S +++ b/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S @@ -16,21 +16,23 @@ #define _CET_ENDBR #endif -#ifdef __APPLE__ -#define HIDDEN .private_extern +#if defined(__APPLE__) +#define HIDDEN(symbol) .private_extern symbol +#elif defined(__ELF__) +#define HIDDEN(symbol) .hidden symbol #else -#define HIDDEN .hidden +#define HIDDEN(symbol) #endif .intel_syntax noprefix -HIDDEN _blake3_hash_many_avx512 -HIDDEN blake3_hash_many_avx512 -HIDDEN blake3_compress_in_place_avx512 -HIDDEN _blake3_compress_in_place_avx512 -HIDDEN blake3_compress_xof_avx512 -HIDDEN _blake3_compress_xof_avx512 -HIDDEN blake3_xof_many_avx512 -HIDDEN _blake3_xof_many_avx512 +HIDDEN(_blake3_hash_many_avx512) +HIDDEN(blake3_hash_many_avx512) +HIDDEN(blake3_compress_in_place_avx512) +HIDDEN(_blake3_compress_in_place_avx512) +HIDDEN(blake3_compress_xof_avx512) +HIDDEN(_blake3_compress_xof_avx512) +HIDDEN(blake3_xof_many_avx512) +HIDDEN(_blake3_xof_many_avx512) .global _blake3_hash_many_avx512 .global blake3_hash_many_avx512 .global blake3_compress_in_place_avx512 diff --git a/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S index d69a1706fefe7..5563fc3b5ba09 100644 --- a/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S +++ b/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S @@ -16,19 +16,21 @@ #define _CET_ENDBR #endif -#ifdef __APPLE__ -#define HIDDEN .private_extern +#if defined(__APPLE__) +#define HIDDEN(symbol) .private_extern symbol +#elif defined(__ELF__) +#define HIDDEN(symbol) .hidden symbol #else -#define HIDDEN .hidden +#define HIDDEN(symbol) #endif .intel_syntax noprefix -HIDDEN blake3_hash_many_sse2 -HIDDEN _blake3_hash_many_sse2 -HIDDEN blake3_compress_in_place_sse2 -HIDDEN _blake3_compress_in_place_sse2 -HIDDEN blake3_compress_xof_sse2 -HIDDEN _blake3_compress_xof_sse2 +HIDDEN(blake3_hash_many_sse2) +HIDDEN(_blake3_hash_many_sse2) +HIDDEN(blake3_compress_in_place_sse2) +HIDDEN(_blake3_compress_in_place_sse2) +HIDDEN(blake3_compress_xof_sse2) +HIDDEN(_blake3_compress_xof_sse2) .global blake3_hash_many_sse2 .global _blake3_hash_many_sse2 .global blake3_compress_in_place_sse2 diff --git a/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S index c5b103af61c4f..5866bfb7ae461 100644 --- a/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S +++ b/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S @@ -16,19 +16,21 @@ #define _CET_ENDBR #endif -#ifdef __APPLE__ -#define HIDDEN .private_extern +#if defined(__APPLE__) +#define HIDDEN(symbol) .private_extern symbol +#elif defined(__ELF__) +#define HIDDEN(symbol) .hidden symbol #else -#define HIDDEN .hidden +#define HIDDEN(symbol) #endif .intel_syntax noprefix -HIDDEN blake3_hash_many_sse41 -HIDDEN _blake3_hash_many_sse41 -HIDDEN blake3_compress_in_place_sse41 -HIDDEN _blake3_compress_in_place_sse41 -HIDDEN blake3_compress_xof_sse41 -HIDDEN _blake3_compress_xof_sse41 +HIDDEN(blake3_hash_many_sse41) +HIDDEN(_blake3_hash_many_sse41) +HIDDEN(blake3_compress_in_place_sse41) +HIDDEN(_blake3_compress_in_place_sse41) +HIDDEN(blake3_compress_xof_sse41) +HIDDEN(_blake3_compress_xof_sse41) .global blake3_hash_many_sse41 .global _blake3_hash_many_sse41 .global blake3_compress_in_place_sse41 diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel index d3bade579f003..1719fc297581f 100644 --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel @@ -2,6 +2,8 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +load("@bazel_skylib//rules:run_binary.bzl", "run_binary") +load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("@rules_python//python:defs.bzl", "py_binary") load( @@ -577,23 +579,18 @@ exports_files( glob(["include/**/*.td"]), ) -genrule( +write_file( name = "basic_version_gen", - outs = ["include/clang/Basic/Version.inc"], - cmd = ( - "echo '#define CLANG_VERSION {vers}' >> $@\n" + - "echo '#define CLANG_VERSION_MAJOR {major}' >> $@\n" + - "echo '#define CLANG_VERSION_MAJOR_STRING \"{major}\"' >> $@\n" + - "echo '#define CLANG_VERSION_MINOR {minor}' >> $@\n" + - "echo '#define CLANG_VERSION_PATCHLEVEL {patch}' >> $@\n" + - "echo '#define MAX_CLANG_ABI_COMPAT_VERSION {major}' >> $@\n" + - "echo '#define CLANG_VERSION_STRING \"{vers}\"' >> $@\n" - ).format( - major = LLVM_VERSION_MAJOR, - minor = LLVM_VERSION_MINOR, - patch = LLVM_VERSION_PATCH, - vers = PACKAGE_VERSION, - ), + out = "include/clang/Basic/Version.inc", + content = [ + "#define CLANG_VERSION {}".format(PACKAGE_VERSION), + "#define CLANG_VERSION_MAJOR {}".format(LLVM_VERSION_MAJOR), + "#define CLANG_VERSION_MAJOR_STRING \"{}\"".format(LLVM_VERSION_MAJOR), + "#define CLANG_VERSION_MINOR {}".format(LLVM_VERSION_MINOR), + "#define CLANG_VERSION_PATCHLEVEL {}".format(LLVM_VERSION_PATCH), + "#define MAX_CLANG_ABI_COMPAT_VERSION {}".format(LLVM_VERSION_MAJOR), + "#define CLANG_VERSION_STRING \"{}\"".format(PACKAGE_VERSION), + ], ) cc_library( @@ -611,13 +608,15 @@ cc_library( # TODO: This should get replaced with something that actually generates the # correct version number. -genrule( +write_file( name = "vcs_version_gen", # This should be under lib/Basic, but because of how the include paths # are passed through bazel, it's easier to drop generated files next to # the other includes. - outs = ["include/VCSVersion.inc"], - cmd = "echo '#undef CLANG_REVISION' > $@", + out = "include/VCSVersion.inc", + content = [ + "#undef CLANG_REVISION", + ], ) py_binary( @@ -979,16 +978,21 @@ cc_library( ], ) -genrule( +run_binary( name = "analysis_htmllogger_gen", srcs = [ - "lib/Analysis/FlowSensitive/HTMLLogger.html", "lib/Analysis/FlowSensitive/HTMLLogger.css", + "lib/Analysis/FlowSensitive/HTMLLogger.html", "lib/Analysis/FlowSensitive/HTMLLogger.js", ], outs = ["lib/Analysis/FlowSensitive/HTMLLogger.inc"], - cmd = "$(location :bundle_resources) $@ $(SRCS)", - tools = [":bundle_resources"], + args = [ + "$(execpath lib/Analysis/FlowSensitive/HTMLLogger.inc)", + "$(execpath lib/Analysis/FlowSensitive/HTMLLogger.html)", + "$(execpath lib/Analysis/FlowSensitive/HTMLLogger.css)", + "$(execpath lib/Analysis/FlowSensitive/HTMLLogger.js)", + ], + tool = ":bundle_resources", ) cc_library( @@ -1549,7 +1553,9 @@ cc_library( "lib/Driver", ], linkopts = select({ - "@platforms//os:windows": ["version.lib"], + "//llvm:is_windows_clang_mingw": ["-lversion"], + "//llvm:is_windows_clang_cl": ["version.lib"], + "//llvm:is_windows_msvc": ["version.lib"], "//conditions:default": [], }), textual_hdrs = glob([ diff --git a/utils/bazel/llvm-project-overlay/lld/BUILD.bazel b/utils/bazel/llvm-project-overlay/lld/BUILD.bazel index 1118f5e81f7ed..628c01112a5d3 100644 --- a/utils/bazel/llvm-project-overlay/lld/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/lld/BUILD.bazel @@ -2,6 +2,7 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@rules_cc//cc:defs.bzl", "cc_library") load( "//:vars.bzl", @@ -19,17 +20,21 @@ package( licenses(["notice"]) # TODO: Actually compute version info -genrule( +write_file( name = "config_version_gen", - outs = ["include/lld/Common/Version.inc"], - cmd = "echo '#define LLD_VERSION_STRING \"{}\"' > $@".format(LLVM_VERSION), + out = "include/lld/Common/Version.inc", + content = [ + "#define LLD_VERSION_STRING \"{}\"".format(LLVM_VERSION), + ], ) -genrule( +write_file( name = "vcs_version_gen", - outs = ["Common/VCSVersion.inc"], - cmd = "echo '#undef LLD_REVISION' >> $@\n" + - "echo '#undef LLD_REPOSITORY' >> $@\n", + out = "Common/VCSVersion.inc", + content = [ + "#undef LLD_REVISION", + "#undef LLD_REPOSITORY", + ], ) # See https://github.com/bazelbuild/bazel/issues/13803 diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel index 127bd7968ef0a..fcf13ab3b8735 100644 --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -4,6 +4,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag") load("@bazel_skylib//rules:expand_template.bzl", "expand_template") +load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("@rules_python//python:defs.bzl", "py_binary") load("@rules_shell//shell:sh_binary.bzl", "sh_binary") @@ -208,18 +209,40 @@ cc_library( deps = [":config"], ) -genrule( +write_file( name = "generate_vcs_revision", - outs = ["include/llvm/Support/VCSRevision.h"], - cmd = "echo '#undef LLVM_REVISION' >> $@\n" + - "echo '#undef LLVM_REPOSITORY' >> $@\n", + out = "include/llvm/Support/VCSRevision.h", + content = [ + "#undef LLVM_REVISION", + "#undef LLVM_REPOSITORY", + ], ) -genrule( +write_file( name = "generate_static_extension_registry", - outs = ["include/llvm/Support/Extension.def"], - cmd = "echo -e '// extension handlers' >> $@\n" + - "echo -e '#undef HANDLE_EXTENSION' >> $@\n", + out = "include/llvm/Support/Extension.def", + content = [ + "// extension handlers", + "#undef HANDLE_EXTENSION", + ], +) + +config_setting( + name = "is_windows_clang_mingw", + constraint_values = ["@platforms//os:windows"], + flag_values = {"@rules_cc//cc/compiler:compiler": "clang"}, +) + +config_setting( + name = "is_windows_clang_cl", + constraint_values = ["@platforms//os:windows"], + flag_values = {"@rules_cc//cc/compiler:compiler": "clang-cl"}, +) + +config_setting( + name = "is_windows_msvc", + constraint_values = ["@platforms//os:windows"], + flag_values = {"@rules_cc//cc/compiler:compiler": "msvc-cl"}, ) cc_library( @@ -297,7 +320,21 @@ cc_library( }), includes = ["include"], linkopts = select({ - "@platforms//os:windows": [ + ":is_windows_clang_mingw": [ + "-lole32", + "-luuid", + "-lws2_32", + "-lntdll", + ], + ":is_windows_clang_cl": [ + "ole32.lib", + "uuid.lib", + "ws2_32.lib", + "ntdll.lib", + ], + ":is_windows_msvc": [ + "ole32.lib", + "uuid.lib", "ws2_32.lib", "ntdll.lib", ],