Skip to content

[clang-doc] fix bug introduced by asset test #97540

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 10 commits into from
Jul 5, 2024

Conversation

PeterChou1
Copy link
Contributor

@PeterChou1 PeterChou1 commented Jul 3, 2024

Fixes #97507
this patch fixes the bug by copying assets to the correct repository for windows builds. It introduces a new global variable
LLVM_SHARE_OUTPUT_INTDIR which points a platform agnostic shared directory

@llvmbot
Copy link
Member

llvmbot commented Jul 3, 2024

@llvm/pr-subscribers-clang-tools-extra

Author: None (PeterChou1)

Changes

Fixes #97507

this patch fixes the bug by copying assets to the correct repository for windows builds


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

1 Files Affected:

  • (modified) clang-tools-extra/clang-doc/tool/CMakeLists.txt (+6-2)
diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
index e93a5728d6b6b..3fd41f187a617 100644
--- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
@@ -25,7 +25,11 @@ set(assets
 )
 
 set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets")
-set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc")
+if(MSVC)
+  set(resource_dir "${CMAKE_BINARY_DIR}/$<CONFIG>/share/clang-doc")
+else()
+  set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc")
+endif()
 set(out_files)
 
 function(copy_files_to_dst src_dir dst_dir file)
@@ -52,4 +56,4 @@ add_custom_target(copy-clang-doc-assets
   COMMENT "Copying Clang-Doc Assets"
 )
 set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets")
-add_dependencies(clang-doc copy-clang-doc-assets)
+add_dependencies(clang-doc copy-clang-doc-assets)
\ No newline at end of file

@PeterChou1 PeterChou1 changed the title [clang-doc] fix path bug introduced by asset test [clang-doc] fix bug introduced by asset test Jul 3, 2024
@ilovepi
Copy link
Contributor

ilovepi commented Jul 3, 2024

seems to fail on windows CI.

Copy link
Collaborator

@dyung dyung left a comment

Choose a reason for hiding this comment

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

I believe (and the pre-merge testing seems to validate my belief) that this breaks the case where you build with ninja + Visual Studio. Also, I believe the Xcode generator is similar to the Visual Studio generator in that they both are multi-config generators, so that configuration is likely failing as well.

@PeterChou1
Copy link
Contributor Author

I believe (and the pre-merge testing seems to validate my belief) that this breaks the case where you build with ninja + Visual Studio. Also, I believe the Xcode generator is similar to the Visual Studio generator in that they both are multi-config generators, so that configuration is likely failing as well.

@ilovepi

I don't have access to a mac could you run build for checking clang-doc in xcode to see if it reports any errors?

@ilovepi
Copy link
Contributor

ilovepi commented Jul 3, 2024

I believe (and the pre-merge testing seems to validate my belief) that this breaks the case where you build with ninja + Visual Studio. Also, I believe the Xcode generator is similar to the Visual Studio generator in that they both are multi-config generators, so that configuration is likely failing as well.

@ilovepi

I don't have access to a mac could you run build for checking clang-doc in xcode to see if it reports any errors?

while I have access to a mac, I don't have the ability to use XCode due to company policy.

@petrhosek
Copy link
Member

We already have set of CMake variables that we use to refer to bin or lib directory which account for various configurations:

# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
if(WIN32 OR CYGWIN)
# DLL platform -- put DLLs into bin.
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
else()
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
endif()
# Each of them corresponds to llvm-config's.
set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir
set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir
set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix
# Note: LLVM_CMAKE_DIR does not include generated files
set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)

I think we should introduce another one for the share directory and use that.

@PeterChou1
Copy link
Contributor Author

We already have set of CMake variables that we use to refer to bin or lib directory which account for various configurations:

# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
if(WIN32 OR CYGWIN)
# DLL platform -- put DLLs into bin.
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
else()
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
endif()
# Each of them corresponds to llvm-config's.
set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir
set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir
set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix
# Note: LLVM_CMAKE_DIR does not include generated files
set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)

I think we should introduce another one for the share directory and use that.

I've introduced a variable in the root cmakelists.txt I'm not very familiar with cmake though I'm sure if this is the correct approach

@PeterChou1
Copy link
Contributor Author

@dyung I do not have access to mac for xcode could you provide me with a log of the build failure on xcode

@dyung
Copy link
Collaborator

dyung commented Jul 3, 2024

@dyung I do not have access to mac for xcode could you provide me with a log of the build failure on xcode

% python3 ~/src/git/llvm-dyung/build/Debug/bin/llvm-lit -v basic-project.test
-- Testing: 1 tests, 1 workers --
FAIL: Clang Tools :: clang-doc/basic-project.test (1 of 1)
******************** TEST 'Clang Tools :: clang-doc/basic-project.test' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
Emiting docs in html format.

--
Command Output (stderr):
--
RUN: at line 1: rm -rf /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp && mkdir -p /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
+ rm -rf /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp
+ mkdir -p /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
RUN: at line 2: sed 's|$test_dir|/Users/dyung/src/git/llvm-dyung/clang-tools-extra/test/clang-doc|g' /Users/dyung/src/git/llvm-dyung/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json > /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ sed 's|$test_dir|/Users/dyung/src/git/llvm-dyung/clang-tools-extra/test/clang-doc|g' /Users/dyung/src/git/llvm-dyung/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
RUN: at line 3: clang-doc --format=html --output=/Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs --executor=all-TUs /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ clang-doc --format=html --output=/Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs --executor=all-TUs /Users/dyung/src/git/llvm-dyung/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
default index.js file missing at /Users/dyung/src/git/llvm-dyung/build/Debug/bin/../share/clang-doc/index.js

This was run using the current HEAD, 4c63672.

@PeterChou1 PeterChou1 requested review from ilovepi and dyung July 3, 2024 23:04
@PeterChou1
Copy link
Contributor Author

PeterChou1 commented Jul 4, 2024

I've added the install path using a platform agnostic variable LLVM_SHARE_OUTPUT_INTDIR which should fix build path problems

@PeterChou1 PeterChou1 merged commit 1ed84a8 into llvm:main Jul 5, 2024
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 5, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-darwin running on doug-worker-3 while building clang-tools-extra,llvm at step 6 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'lit :: shtest-external-shell-kill.py' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 23
env -u FILECHECK_OPTS "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9" /Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/llvm/utils/lit/lit.py -j1 --order=lexical -a Inputs/shtest-external-shell-kill | grep -v 'bash.exe: warning: could not find /tmp, please create!' | FileCheck /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py
# executed command: env -u FILECHECK_OPTS /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 /Users/buildbot/buildbot-root/x86_64-darwin/llvm-project/llvm/utils/lit/lit.py -j1 --order=lexical -a Inputs/shtest-external-shell-kill
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: grep -v 'bash.exe: warning: could not find /tmp, please create!'
# executed command: FileCheck /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py
# .---command stderr------------
# | /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py:29:15: error: CHECK-NEXT: is not on the line after the previous match
# | # CHECK-NEXT: end
# |               ^
# | <stdin>:22:22: note: 'next' match was here
# | RUN: at line 5: echo end
# |                      ^
# | <stdin>:8:6: note: previous match ended here
# | start
# |      ^
# | <stdin>:9:1: note: non-matching line after previous match is here
# | 
# | ^
# | 
# | Input file: <stdin>
# | Check file: /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |          .
# |          .
# |          .
# |         17: RUN: at line 3: sleep 2 
# |         18: + sleep 2 
# |         19: + sleep 300 
# |         20: RUN: at line 4: kill $PID 
# |         21: + kill 50384 
# |         22: RUN: at line 5: echo end 
# | next:29                          !~~  error: match on wrong line
# |         23: /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/utils/lit/tests/Inputs/shtest-external-shell-kill/Output/test.txt.script: line 5: echo: write error: Interrupted system call 
# |         24: /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/utils/lit/tests/Inputs/shtest-external-shell-kill/Output/test.txt.script: line 6: 50384 Terminated: 15 sleep 300 
# |         25:  
# |         26: -- 
# |         27:  
# |          .
# |          .
...

kbluck pushed a commit to kbluck/llvm-project that referenced this pull request Jul 6, 2024
@mgorny
Copy link
Member

mgorny commented Jul 6, 2024

This change broke standalone clang builds against installed LLVM, since LLVM_SHARE_OUTPUT_INTDIR is not exported by LLVM and therefore resolves to an empty path:

ninja: error: mkdir(/clang-doc): Permission denied
ninja: build stopped: .

Why are you even declaring the directory inside LLVM when it's only used by Clang?

Please revert.

PeterChou1 added a commit that referenced this pull request Jul 6, 2024
reverts #97540

which broke clangs standalone build
@mgorny
Copy link
Member

mgorny commented Jul 10, 2024

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test clang-tools-extra/test/clang-doc/basic-project.test failing when built using non-ninja generator
7 participants