Skip to content

[CMake] adjust clang resource dir symlinks to new path #66983

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

Conversation

edymtt
Copy link
Contributor

@edymtt edymtt commented Jun 28, 2023

As a result of llvm/llvm-project@e1b88c8a09be we should expect it to contain only the major version, not the full one -- that is, we should expect it to be

 ../lib/clang/CLANG_VERSION_MAJOR

instead of

../lib/clang/CLANG_VERSION_MAJOR.CLANG_VERSION_MINOR.CLANG_VERSION_PATCH

Also update the logic to levarage directly the Clang version -- this can
be different from the LLVM one (as per
llvm/llvm-project@ebfc680)

Addresses rdar://111452821

@edymtt
Copy link
Contributor Author

edymtt commented Jun 28, 2023

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Jun 28, 2023

macOS is failing with expected errors related to llvm::Optional

@edymtt
Copy link
Contributor Author

edymtt commented Jun 28, 2023

Windows seems failing to build LLVM

FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/COM.cpp.obj 
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1429~1.300\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_LIBCPP_ENABLE_ASSERTIONS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib\Support -IC:\Users\swift-ci\jenkins\workspace\swift-PR-windows\llvm-project\llvm\lib\Support -Iinclude -IC:\Users\swift-ci\jenkins\workspace\swift-PR-windows\llvm-project\llvm\include /GS- /Oy /Gw /Gy /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2 -UNDEBUG -std:c++17  /EHs-c- /GR- /showIncludes /Folib\Support\CMakeFiles\LLVMSupport.dir\COM.cpp.obj /Fdlib\Support\CMakeFiles\LLVMSupport.dir\LLVMSupport.pdb /FS -c C:\Users\swift-ci\jenkins\workspace\swift-PR-windows\llvm-project\llvm\lib\Support\COM.cpp
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\oaidl.h(487): warning C5103: pasting '/' and '/' does not result in a valid preprocessing token
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared\wtypes.h(745): note: in expansion of macro '_VARIANT_BOOL'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\oaidl.h(487): error C2059: syntax error: '/'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\oaidl.h(487): error C2238: unexpected token(s) preceding ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\oaidl.h(502): warning C5103: pasting '/' and '/' does not result in a valid preprocessing token
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared\wtypes.h(745): note: in expansion of macro '_VARIANT_BOOL'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\oaidl.h(502): error C2059: syntax error: '/'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\oaidl.h(502): error C2238: unexpected token(s) preceding ';'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\propidlbase.h(319): warning C5103: pasting '/' and '/' does not result in a valid preprocessing token
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared\wtypes.h(745): note: in expansion of macro '_VARIANT_BOOL'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\propidlbase.h(319): error C2059: syntax error: '/'
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\propidlbase.h(319): error C2238: unexpected token(s) preceding ';

@edymtt
Copy link
Contributor Author

edymtt commented Jun 28, 2023

Linux will require building a newer CMake

+ env /home/build-user/build/cmake-linux-x86_64/bin/cmake ... /home/build-user/llvm-project/llvm
CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
  CMake 3.20.0 or higher is required.  You are running version 3.19.6

Update tracked in #67018

@edymtt
Copy link
Contributor Author

edymtt commented Jun 29, 2023

The Windows issue sounds similar to the reported at dotnet/runtime#50342, which suggest we may need to use a newer Windows 10 SDK

@edymtt
Copy link
Contributor Author

edymtt commented Jun 29, 2023

Before retesting Linux, waiting for #67018

@etcwilde
Copy link
Member

/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-next/llvm-project/llvm/include/llvm/Support/Format.h:220:3: error: no template named 'optional' in namespace 'std'; did you mean 'Optional'?
  220 |   std::optional<uint64_t> FirstByteOffset;
      |   ^~~~~~~~~~~~~
      |   Optional

This is actually interesting. LLVM should be using std::optional, not llvm::Optional.

@edymtt
Copy link
Contributor Author

edymtt commented Jul 3, 2023

@swift-ci please test macOS

@edymtt
Copy link
Contributor Author

edymtt commented Jul 3, 2023

@swift-ci please test Windows

@edymtt
Copy link
Contributor Author

edymtt commented Jul 4, 2023

@swift-ci please clean test macOS

@edymtt
Copy link
Contributor Author

edymtt commented Jul 4, 2023

@swift-ci please clean test Windows

@edymtt
Copy link
Contributor Author

edymtt commented Jul 5, 2023

/Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-next/llvm-project/llvm/include/llvm/Support/Format.h:220:3: error: no template named 'optional' in namespace 'std'; did you mean 'Optional'?
  220 |   std::optional<uint64_t> FirstByteOffset;
      |   ^~~~~~~~~~~~~
      |   Optional

This is actually interesting. LLVM should be using std::optional, not llvm::Optional.

I can repro this failure locally if I use Xcode 14.2 to build next -- it disappears when I use Xcode 14.3 (i.e. for SwiftRemoteMirror I only get error: no member named 'popcount' in namespace 'llvm')

@etcwilde
Copy link
Member

etcwilde commented Jul 6, 2023

swiftlang/llvm-project#7058

@swift-ci please test

@etcwilde
Copy link
Member

etcwilde commented Jul 6, 2023

We will likely run into this error here since LLVM requires a newer CMake version:

CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
  CMake 3.20.0 or higher is required.  You are running version 3.19.6

@edymtt
Copy link
Contributor Author

edymtt commented Jul 11, 2023

Investigated at desk the Windows failure -- this is related to the enablement of the standard conforming preprocessor in LLVM

According to the related review, we would need 10.0.20348.0 or later -- this is further confirmed in other blog posts as well

@edymtt
Copy link
Contributor Author

edymtt commented Jul 11, 2023

@swift-ci please test Linux

@edymtt
Copy link
Contributor Author

edymtt commented Jul 11, 2023

@swift-ci please test macOS

@@ -94,7 +91,8 @@ if(NOT SWIFT_INCLUDE_TOOLS AND
endif()
message(STATUS "Using clang Resource Directory: ${clang_headers_location}")
else()
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
# ... or the one we just built
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${LLVM_VERSION_MAJOR}")
Copy link
Member

Choose a reason for hiding this comment

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

Should these (this and the one down on line 206) be CLANG_VERSION_MAJOR instead of LLVM_VERSION_MAJOR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point -- I wrongly assumed they are set to the same value, but that could not be the case (as per llvm/llvm-project@ebfc680)

Since CLANG_VERSION_MAJOR is not reexported by ClangConfig.cmake, I need to update the check before as well to ensure we specify that when configuring the Swift build system.

Addressed this in 6b3ecfb

@edymtt edymtt force-pushed the edymtt/change-clang-resource-dir-references branch from a778b1e to 6b3ecfb Compare July 25, 2023 16:27
@edymtt
Copy link
Contributor Author

edymtt commented Jul 25, 2023

@swift-ci please test

@edymtt edymtt force-pushed the edymtt/change-clang-resource-dir-references branch from 6b3ecfb to 99fb4e1 Compare July 25, 2023 20:00
@edymtt
Copy link
Contributor Author

edymtt commented Jul 25, 2023

@swift-ci please test

As a result of llvm/llvm-project@e1b88c8a09be
we should expect it to contain only the major version, not the full one
-- that is, we should expect it to be

```
../lib/clang/CLANG_VERSION_MAJOR
```

instead of

```
../lib/clang/CLANG_VERSION_MAJOR.CLANG_VERSION_MINOR.CLANG_VERSION_PATCH
```

Also update the logic to levarage directly the Clang version -- this can
be different from the LLVM one (as per
llvm/llvm-project@ebfc680)

Addresses rdar://111452821
@edymtt edymtt force-pushed the edymtt/change-clang-resource-dir-references branch from 99fb4e1 to 47cd49d Compare July 25, 2023 20:47
@edymtt
Copy link
Contributor Author

edymtt commented Jul 25, 2023

@swift-ci please test

@edymtt edymtt changed the base branch from next to rebranch July 28, 2023 14:20
@edymtt
Copy link
Contributor Author

edymtt commented Jul 28, 2023

@swift-ci please test

1 similar comment
@edymtt
Copy link
Contributor Author

edymtt commented Jul 31, 2023

@swift-ci please test

@edymtt
Copy link
Contributor Author

edymtt commented Jul 31, 2023

@swift-ci please test Linux

1 similar comment
@edymtt
Copy link
Contributor Author

edymtt commented Jul 31, 2023

@swift-ci please test Linux

@edymtt edymtt merged commit 72cd8bf into swiftlang:rebranch Jul 31, 2023
@edymtt edymtt deleted the edymtt/change-clang-resource-dir-references branch August 1, 2023 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants