Skip to content

Conversation

ahatanak
Copy link
Collaborator

Use LLVM_VERSION_MAJOR instead as the maximum allowed value. This change is needed to fix regression tests that fail
when vendors set CLANG_VERSION_MAJOR to a value that is lower than LLVM_VERSION_MAJOR when building the
compiler.

For example, clang/test/CodeGenCXX/mangle-concept.cpp fails with the following error if -DCLANG_VERSION_MAJOR=17
is passed to cmake:

invalid value '19' in '-fclang-abi-compat=19'

-fclang-abi-compat= is valid

Use LLVM_VERSION_MAJOR instead as the maximum allowed value. This change
is needed to fix regression tests that fail when vendors set
CLANG_VERSION_MAJOR to a value that is lower than LLVM_VERSION_MAJOR
when building the compiler.

For example, clang/test/CodeGenCXX/mangle-concept.cpp fails with the
following error if -DCLANG_VERSION_MAJOR=17 is passed to cmake:

invalid value '19' in '-fclang-abi-compat=19'
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 22, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 22, 2025

@llvm/pr-subscribers-clang

Author: Akira Hatanaka (ahatanak)

Changes

Use LLVM_VERSION_MAJOR instead as the maximum allowed value. This change is needed to fix regression tests that fail
when vendors set CLANG_VERSION_MAJOR to a value that is lower than LLVM_VERSION_MAJOR when building the
compiler.

For example, clang/test/CodeGenCXX/mangle-concept.cpp fails with the following error if -DCLANG_VERSION_MAJOR=17
is passed to cmake:

invalid value '19' in '-fclang-abi-compat=19'


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

3 Files Affected:

  • (modified) clang/CMakeLists.txt (+1)
  • (modified) clang/include/clang/Basic/Version.inc.in (+1)
  • (modified) clang/lib/Frontend/CompilerInvocation.cpp (+1-1)
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index b79e570667b2c4..4a18ecf8d2a757 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -331,6 +331,7 @@ if(NOT DEFINED CLANG_VERSION_SUFFIX)
   set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
 endif()
 set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}")
+set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}")
 message(STATUS "Clang version: ${CLANG_VERSION}")
 
 # Configure the Version.inc file.
diff --git a/clang/include/clang/Basic/Version.inc.in b/clang/include/clang/Basic/Version.inc.in
index 370da8506d1425..69c79d03861cd2 100644
--- a/clang/include/clang/Basic/Version.inc.in
+++ b/clang/include/clang/Basic/Version.inc.in
@@ -4,3 +4,4 @@
 #define CLANG_VERSION_MAJOR_STRING "@CLANG_VERSION_MAJOR@"
 #define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
 #define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
+#define MAX_CLANG_ABI_COMPAT_VERSION @MAX_CLANG_ABI_COMPAT_VERSION@
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d711df02ce9503..09eb0517544a27 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4387,7 +4387,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
     // y or y.0 (4 <= y <= current version).
     if (!VerParts.first.starts_with("0") &&
         !VerParts.first.getAsInteger(10, Major) && 3 <= Major &&
-        Major <= CLANG_VERSION_MAJOR &&
+        Major <= MAX_CLANG_ABI_COMPAT_VERSION &&
         (Major == 3
              ? VerParts.second.size() == 1 &&
                    !VerParts.second.getAsInteger(10, Minor)

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM

@ahatanak ahatanak merged commit 6092740 into llvm:main Jan 29, 2025
11 checks passed
@ahatanak ahatanak deleted the max-clang-abi-compat-version branch January 29, 2025 02:59
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 29, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building clang at step 7 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: UBSan-Minimal-x86_64 :: TestCases/implicit-integer-sign-change.c (93969 of 98033)
PASS: UBSan-Minimal-x86_64 :: TestCases/implicit-unsigned-integer-truncation.c (93970 of 98033)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/TypeCheck/vptr-virtual-base-construction.cpp (93971 of 98033)
PASS: UBSan-Minimal-x86_64 :: TestCases/override-callback.c (93972 of 98033)
PASS: UBSan-Minimal-x86_64 :: TestCases/implicit-signed-integer-truncation.c (93973 of 98033)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/TypeCheck/vptr-virtual-base.cpp (93974 of 98033)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/TypeCheck/vptr-corrupted-vtable-itanium.cpp (93975 of 98033)
PASS: UBSan-Minimal-x86_64 :: TestCases/recover-dedup.cpp (93976 of 98033)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Pointer/align-assume-ignorelist.cpp (93977 of 98033)
TIMEOUT: MLIR :: Examples/standalone/test.toy (93978 of 98033)
******************** TEST 'MLIR :: Examples/standalone/test.toy' FAILED ********************
Exit Code: 1
Timeout: Reached timeout of 60 seconds

Command Output (stdout):
--
# RUN: at line 1
"/etc/cmake/bin/cmake" "/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone" -G "Ninja"  -DCMAKE_CXX_COMPILER=/usr/bin/clang++  -DCMAKE_C_COMPILER=/usr/bin/clang   -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir  -DLLVM_USE_LINKER=lld  -DPython3_EXECUTABLE="/usr/bin/python3.10"
# executed command: /etc/cmake/bin/cmake /build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld -DPython3_EXECUTABLE=/usr/bin/python3.10
# .---command stdout------------
# | -- The CXX compiler identification is Clang 16.0.6
# | -- The C compiler identification is Clang 16.0.6
# | -- Detecting CXX compiler ABI info
# | -- Detecting CXX compiler ABI info - done
# | -- Check for working CXX compiler: /usr/bin/clang++ - skipped
# | -- Detecting CXX compile features
# | -- Detecting CXX compile features - done
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - done
# | -- Check for working C compiler: /usr/bin/clang - skipped
# | -- Detecting C compile features
# | -- Detecting C compile features - done
# | -- Looking for histedit.h
# | -- Looking for histedit.h - found
# | -- Found LibEdit: /usr/include (found version "2.11") 
# | -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
# | -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.13") 
# | -- Using MLIRConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir
# | -- Using LLVMConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/llvm
# | -- Linker detection: unknown
# | -- Performing Test LLVM_LIBSTDCXX_MIN
# | -- Performing Test LLVM_LIBSTDCXX_MIN - Success
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
# | -- Performing Test C_SUPPORTS_FPIC
# | -- Performing Test C_SUPPORTS_FPIC - Success
# | -- Performing Test CXX_SUPPORTS_FPIC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants