[Windows] Adjust exported symbols to filter out profile symbols (#167985)

When building Clang for Windows with clang-cl with -fprofile-generate
and LLVM_EXPORT_SYMBOLS_FOR_PLUGINS, the build fails with
  lld-link: error: too many exported symbols (got 76137, max 65535)

Removing the symbols generated from the use of that flag removes about
13K symbols.
This commit is contained in:
Mike Hommey 2026-02-25 17:45:30 +09:00 committed by GitHub
parent f2a10ab74f
commit 4f4087edb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,6 +128,9 @@ def should_keep_microsoft_symbol(symbol, calling_convention_decoration):
and (symbol.startswith("?Head@") or symbol.startswith("?Tail@"))
):
return symbol
# Skip symbols added by the compiler with -fprofile-generate.
elif symbol.startswith("__prof"):
return None
# Keep mangled llvm:: and clang:: function symbols. How we detect these is a
# bit of a mess and imprecise, but that avoids having to completely demangle
# the symbol name. The outermost namespace is at the end of the identifier