Skip to content

[LLVM][CMake][MSVC] Install PDBs alongside executables #120683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

mayanez
Copy link
Contributor

@mayanez mayanez commented Dec 20, 2024

  • When building on Windows hosts, PDBs aren't installed to the CMAKE_INSTALL_PREFIX.

  • This PR addresses it solely for llvm-* executables.

    • Similar changes are required in AddClang.cmake, AddLLD.cmake, etc. I'd be happy to queue those PRs after this one.

@llvmbot llvmbot added the cmake Build system in general and CMake in particular label Dec 20, 2024
@mayanez mayanez force-pushed the build/cmakepdb branch 2 times, most recently from 2c3e4a9 to ac540f9 Compare December 20, 2024 22:34
@mayanez
Copy link
Contributor Author

mayanez commented Jan 9, 2025

Ping

Should probably also be tagged with windows though I lack permission to do so.

@llvmbot
Copy link
Member

llvmbot commented Jan 14, 2025

@llvm/pr-subscribers-platform-windows

Author: Miguel A. Arroyo (mayanez)

Changes
  • When building on Windows hosts, PDBs aren't installed to the CMAKE_INSTALL_PREFIX.

  • This PR addresses it solely for llvm-* executables.

    • Similar changes are required in AddClang.cmake, AddLLD.cmake, etc. I'd be happy to queue those PRs after this one.

Full diff: https://github.com/llvm/llvm-project/pull/120683.diff

1 Files Affected:

  • (modified) llvm/cmake/modules/AddLLVM.cmake (+15)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 54a54db338e695..48e2dfef148419 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1489,6 +1489,11 @@ macro(llvm_add_tool project name)
                 ${export_to_llvmexports}
                 RUNTIME DESTINATION ${${project}_TOOLS_INSTALL_DIR}
                 COMPONENT ${name})
+        if (MSVC)
+          install(FILES $<TARGET_PDB_FILE:${name}> 
+                DESTINATION "${${project}_TOOLS_INSTALL_DIR}" COMPONENT ${name} 
+                OPTIONAL)
+        endif()
 
         if (NOT LLVM_ENABLE_IDE)
           add_llvm_install_targets(install-${name}
@@ -1519,6 +1524,11 @@ macro(add_llvm_example name)
   add_llvm_executable(${name} EXPORT_SYMBOLS ${ARGN})
   if( LLVM_BUILD_EXAMPLES )
     install(TARGETS ${name} RUNTIME DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}")
+    if (MSVC)
+      install(FILES $<TARGET_PDB_FILE:${name}> 
+              DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}" COMPONENT ${name} 
+              OPTIONAL)
+    endif()
   endif()
   get_subproject_title(subproject_title)
   set_target_properties(${name} PROPERTIES FOLDER "${subproject_title}/Examples")
@@ -1553,6 +1563,11 @@ macro(add_llvm_utility name)
               ${export_to_llvmexports}
               RUNTIME DESTINATION ${LLVM_UTILS_INSTALL_DIR}
               COMPONENT ${name})
+      if (MSVC)
+        install(FILES $<TARGET_PDB_FILE:${name}> 
+                DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT ${name} 
+                OPTIONAL)
+      endif()
 
       if (NOT LLVM_ENABLE_IDE)
         add_llvm_install_targets(install-${name}

@aganea
Copy link
Member

aganea commented Jan 14, 2025

I think the reason why we weren’t doing it before is a concern of installation size. I agree having the PDBs would be useful. I’d rather prefer publishing them on a symbol server, and pull them on-demand instead.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you should use LLVM_ENABLE_PDB instead of MSVC for the condition. However, I agree with @aganea that size is a concern. OTOH, this is primarily either used for staging and then subsequently building the installer (which could/would drop the PDB, so the distribution size shouldn't be impacted, in theory) or it is for the developer installing it to the system for some reason.

I think that @zmodem should verify that the installer would not package up the PDBs.

@mayanez
Copy link
Contributor Author

mayanez commented Jan 14, 2025

I think that you should use LLVM_ENABLE_PDB instead of MSVC for the condition.

That's a good callout! I can make the change for that.

I’d rather prefer publishing them on a symbol server, and pull them on-demand instead

While orthogonal, wouldn't having them in the install directory simplify having to fetch all the PDBs to be deployed?

I think that @zmodem should verify that the installer would not package up the PDBs.

Yes, if the installer doesn't pick it up that would be ideal. Otherwise, I can take a look at that next.

@zmodem
Copy link
Collaborator

zmodem commented Jan 15, 2025

I think that @zmodem should verify that the installer would not package up the PDBs.

Yes, if the installer doesn't pick it up that would be ideal. Otherwise, I can take a look at that next.

I think with the current version of the patch, the PDBs would end up in the installer (I didn't have time to try it yet though). However if you gate it behind LLVM_ENABLE_PDB they would not (the installers are built by llvm/utils/release/build_llvm_release.bat which does not set that flag).

@mayanez
Copy link
Contributor Author

mayanez commented Jan 16, 2025

I've updated it to use LLVM_ENABLE_PDB and will use the same for subsequent PRs.

@mayanez mayanez requested a review from compnerd February 4, 2025 04:45
@mayanez mayanez merged commit 9d134f2 into llvm:main Feb 11, 2025
8 checks passed
@mayanez mayanez deleted the build/cmakepdb branch February 11, 2025 05:50
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
* When building on Windows hosts, PDBs aren't installed to the
`CMAKE_INSTALL_PREFIX`.

* This PR addresses it solely for `llvm-*` executables. 
* Similar changes are required in `AddClang.cmake`, `AddLLD.cmake`, etc.
I'd be happy to queue those PRs after this one.
mayanez added a commit that referenced this pull request Feb 12, 2025
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 12, 2025
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
* When building on Windows hosts, PDBs aren't installed to the
`CMAKE_INSTALL_PREFIX`.

* This PR addresses it solely for `llvm-*` executables. 
* Similar changes are required in `AddClang.cmake`, `AddLLD.cmake`, etc.
I'd be happy to queue those PRs after this one.
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
* When building on Windows hosts, PDBs aren't installed to the
`CMAKE_INSTALL_PREFIX`.

* This PR addresses it solely for `llvm-*` executables. 
* Similar changes are required in `AddClang.cmake`, `AddLLD.cmake`, etc.
I'd be happy to queue those PRs after this one.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 18, 2025

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-multistage running on systemz-1 while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/98/builds/1156

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'libFuzzer-s390x-default-Linux :: fuzzer-timeout.test' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer  /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
RUN: at line 2: /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer  /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
RUN: at line 3: not  /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 2>&1 | FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=TimeoutTest
+ not /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1
+ FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=TimeoutTest
RUN: at line 12: not  /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/hi.txt 2>&1 | FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=SingleInputTimeoutTest
+ not /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/hi.txt
+ FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=SingleInputTimeoutTest
RUN: at line 16: /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 -timeout_exitcode=0
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux-multistage/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 -timeout_exitcode=0
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 119645028
INFO: Loaded 1 modules   (13 inline 8-bit counters): 13 [0x2aa2e650e80, 0x2aa2e650e8d), 
INFO: Loaded 1 PC tables (13 PCs): 13 [0x2aa2e650e90,0x2aa2e650f60), 
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: A corpus is not provided, starting from an empty corpus
#2	INITED cov: 2 ft: 2 corp: 1/1b exec/s: 0 rss: 31Mb
#958	NEW    cov: 3 ft: 3 corp: 2/3b lim: 11 exec/s: 0 rss: 31Mb L: 2/2 MS: 1 InsertByte-
#979	NEW    cov: 4 ft: 4 corp: 3/4b lim: 11 exec/s: 0 rss: 32Mb L: 1/2 MS: 1 EraseBytes-
#3080	NEW    cov: 5 ft: 5 corp: 4/18b lim: 29 exec/s: 0 rss: 32Mb L: 14/14 MS: 1 InsertRepeatedBytes-
#3097	REDUCE cov: 5 ft: 5 corp: 4/15b lim: 29 exec/s: 0 rss: 32Mb L: 11/11 MS: 2 CrossOver-EraseBytes-
#3138	REDUCE cov: 5 ft: 5 corp: 4/10b lim: 29 exec/s: 0 rss: 32Mb L: 6/6 MS: 1 EraseBytes-
#3299	REDUCE cov: 5 ft: 5 corp: 4/9b lim: 29 exec/s: 0 rss: 32Mb L: 5/5 MS: 1 EraseBytes-
#3305	REDUCE cov: 5 ft: 5 corp: 4/7b lim: 29 exec/s: 0 rss: 32Mb L: 3/3 MS: 1 EraseBytes-
#3307	REDUCE cov: 6 ft: 6 corp: 5/9b lim: 29 exec/s: 0 rss: 32Mb L: 2/3 MS: 2 ChangeBinInt-EraseBytes-
ALARM: working on the last Unit for 1 seconds
       and the timeout value is 1 (use -timeout=N to change)
MS: 2 ChangeByte-CrossOver-; base unit: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
0x48,0x69,0x21,
Hi!
artifact_prefix='./'; Test unit written to ./timeout-c0a0ad26a634840c67a210fefdda76577b03a111
Base64: SGkh
==2002114== ERROR: libFuzzer: timeout after 1 seconds
AddressSanitizer:DEADLYSIGNAL
=================================================================
AddressSanitizer:DEADLYSIGNAL
=================================================================
AddressSanitizer: CHECK failed: asan_report.cpp:199 "((current_error_.kind)) == ((kErrorKindInvalid))" (0x1, 0x0) (tid=2002114)
    <empty stack>

MS: 2 ChangeByte-CrossOver-; base unit: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
0x48,0x69,0x21,
Hi!
...

mayanez added a commit that referenced this pull request May 23, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request May 23, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular platform:windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants