Sedat Dilek via llvm-dev
2020-May-21 10:45 UTC
[llvm-dev] Understanding the version handling in LLVM/Clang/LLD
[ Please CC me I ma not subcribed to this mailing-list ] [ CC Tom and Hans as LLVM/stable maintainers ] Hi, I want to understand the version handling in LLVM/Clang/LLD. Normally, I build from "release/10.x" Git branch by using the tool tc-build from ClangBuiltLinux project. With "llvm-10.0.1-rc1" Git tag I was able to setup a llvm-toolchain consisting of the projects "clang" and "lld". A Linux v5.7-rc6 was successfully built. $ cat /proc/version Linux version 5.7.0-rc6-2-amd64-clang (sedat.dilek at gmail.com@iniza) (ClangBuiltLinux clang version 10.0.1 (https://github.com/llvm/llvm-project f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6), LLD 10.0.1 (https://github.com/llvm/llvm-project f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6)) #2~bullseye+dileks1 SMP 2020-05-20 I remember when I used official tarballs for RC releases, the version string should look like: $ clang-10 --version dileks clang version 10.0.1rc1 Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/dileks/src/llvm-toolchain/install/bin $ ld.lld --version LLD 10.0.1rc1 (compatible with GNU linkers) $ llvm-as --version LLVM (http://llvm.org/): LLVM version 10.0.1rc1 Optimized build. Default target: x86_64-unknown-linux-gnu Host CPU: sandybridge My first change: [ llvm/CMakeLists.txt ] if(NOT DEFINED LLVM_VERSION_SUFFIX) - set(LLVM_VERSION_SUFFIX "") + set(LLVM_VERSION_SUFFIX "rc1") endif() Unfortunately, clang-10 and ld.lld binaries did not show this in their version. So, I modified clang... [ clang/CMakeLists.txt ] -# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. -set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") +if(NOT DEFINED CLANG_VERSION_SUFFIX) + set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) +endif() +# CLANG_VERSION includes LLVM_VERSION_SUFFIX. +set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}") ...and lld (the same way clang handles its version): [ lld/CMakeLists.txt ] -# Compute the LLD version from the LLVM version. -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLD_VERSION - ${PACKAGE_VERSION}) +# If LLD_VERSION_* is specified, use it, if not use LLVM_VERSION_*. +if(NOT DEFINED LLD_VERSION_MAJOR) + set(LLD_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) +endif() +if(NOT DEFINED LLD_VERSION_MINOR) + set(LLD_VERSION_MINOR ${LLVM_VERSION_MINOR}) +endif() +if(NOT DEFINED LLD_VERSION_PATCHLEVEL) + set(LLD_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) +endif() +if(NOT DEFINED LLD_VERSION_SUFFIX) + set(LLD_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) +endif() +# LLD_VERSION includes LLVM_VERSION_SUFFIX. +set(LLD_VERSION "${LLD_VERSION_MAJOR}.${LLD_VERSION_MINOR}.${LLD_VERSION_PATCHLEVEL}${LLD_VERSION_SUFFIX}") message(STATUS "LLD version: ${LLD_VERSION}") -string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" LLD_VERSION_MAJOR - ${LLD_VERSION}) -string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" LLD_VERSION_MINOR - ${LLD_VERSION}) - That worked like expected for clang-10 and ld.lld with "-v" and/or "--version" options. A clang-test FAILED... Preprocessor/iwithprefix.c (below when using LLVM_VERSION_SUFFIX = "git"): This is because of the "rc1" string in the include path ("git" accordingly): lib/clang/10.0.1rc1/include To fix this up (maybe someone can help to recognize "git" and "rc[1-9]"): [ clang/test/Preprocessor/iwithprefix.c ] -// CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}{{/|\\}}include +// CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}rc1{{/|\\}}include I guess this is due to my introduction and usage of CLANG_VERSION_SUFFIX. Finally, I looked into master Git where I saw: if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX "git") endif() And re-checked every place where especially... ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} ...is used. So, I fixed it up by pre-checking for... if(LLVM_VERSION_SUFFIX STREQUAL "git") Example (full patch attached): [ llvm/cmake/modules/AddLLVM.cmake ] @@ -541,11 +541,18 @@ function(llvm_add_library name) # Set SOVERSION on shared libraries that lack explicit SONAME # specifier, on *nix systems that are not Darwin. if(UNIX AND NOT APPLE AND NOT ARG_SONAME) - set_target_properties(${name} - PROPERTIES - # Since 4.0.0, the ABI version is indicated by the major version - SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} - VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) + # Since 4.0.0, the ABI version is indicated by the major version + if(LLVM_VERSION_SUFFIX STREQUAL "git") + set_target_properties(${name} + PROPERTIES + SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} + VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) + else() + set_target_properties(${name} + PROPERTIES + SOVERSION ${LLVM_VERSION_MAJOR} + VERSION ${LLVM_VERSION_MAJOR}) + endif() endif() endif() @@ -567,8 +574,13 @@ function(llvm_add_library name) if(${output_name} STREQUAL "output_name-NOTFOUND") set(output_name ${name}) endif() - set(library_name ${output_name}-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) - set(api_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}) + if(LLVM_VERSION_SUFFIX STREQUAL "git") + set(library_name ${output_name}-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) + set(api_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}) + else() + set(library_name ${output_name}-${LLVM_VERSION_MAJOR}) + set(api_name ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}) + endif() set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name}) llvm_install_library_symlink(${api_name} ${library_name} SHARED In the end I was able to build a LLVM/Clang/LLD toolchain which shows me "10.0.1rc1" version string for all llvm-*, clang-10 and ld.lld binaries. As I understand the llvm/stable maintainers do not use or bump LLVM_VERSION_SUFFIX with RC releases as I have expected. But I see some problems when people do not use "git" as value in LLVM_VERSION_SUFFIX - like me "rc1". Also, I see an inconsistency for llvm-* binaries when using "git" whereas Clang and LLD do not show this in their version strings. I am not sure what the introduction of CLANG_VERSION_SUFFIX and LLD_VERSION_SUFFIX is all doing. The only value used for LLVM_VERSION_SUFFIX is "git" in master Git branch. Where is LLVM_VERSION_SUFFIX really relevant? What do you think of the usage of LLVM_VERSION_SUFFIX in general? What do you think to the changes to Clang and LLD versioning? Thanks. Regards, - Sedat - P.S.: Some useful outputs FAIL: Clang :: Preprocessor/iwithprefix.c (8758 of 16586) ******************** TEST 'Clang :: Preprocessor/iwithprefix.c' FAILED ******************** Script: -- : 'RUN: at line 3'; rm -rf /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps : 'RUN: at line 4'; mkdir -p /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/first /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/second : 'RUN: at line 5'; /home/dileks/src/llvm-toolchain/build/stage1/bin/clang -cc1 -internal-isystem /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include -nostdsysteminc -triple x86_64-unknown-unknown -iprefix /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/ -iwithprefix second -isystem /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/first -v /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c 2> /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.out : 'RUN: at line 8'; /home/dileks/src/llvm-toolchain/build/stage1/bin/FileCheck /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c < /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.out -- Exit Code: 1 Command Output (stderr): -- /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c:12:11: error: CHECK: expected string not found in input // CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}{{/|\\}}include ^ <stdin>:6:2: note: scanning from here /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include ^ <stdin>:6:45: note: possible intended match here /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include [ scripts/run_tests_20200520.sh ] #!/bin/sh export LANG=C export LC_ALL=C CLANG_TESTS="Preprocessor/iwithprefix.c" LLVM_LIT_OPTS="--verbose --echo-all-commands --show-all" cd build/stage1/ for t in $CLANG_TESTS ; do ./bin/llvm-lit $LLVM_LIT_OPTS ./tools/clang/test/$t ; done - EOT -
Sedat Dilek via llvm-dev
2020-May-21 10:46 UTC
[llvm-dev] Understanding the version handling in LLVM/Clang/LLD
Forgot the patch. - Sedat - -------------- next part -------------- A non-text attachment was scrubbed... Name: LLVM_VERSION_SUFFIX-v4.diff Type: text/x-patch Size: 5671 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200521/09803199/attachment-0001.bin>
Tom Stellard via llvm-dev
2020-May-21 14:30 UTC
[llvm-dev] Understanding the version handling in LLVM/Clang/LLD
On 05/21/2020 03:45 AM, Sedat Dilek wrote:> [ Please CC me I ma not subcribed to this mailing-list ] > > [ CC Tom and Hans as LLVM/stable maintainers ] > > Hi, > > I want to understand the version handling in LLVM/Clang/LLD. > > Normally, I build from "release/10.x" Git branch by using the tool > tc-build from ClangBuiltLinux project. > > With "llvm-10.0.1-rc1" Git tag I was able to setup a llvm-toolchain > consisting of the projects "clang" and "lld". > > A Linux v5.7-rc6 was successfully built. > > $ cat /proc/version > Linux version 5.7.0-rc6-2-amd64-clang (sedat.dilek at gmail.com@iniza) > (ClangBuiltLinux clang version 10.0.1 > (https://github.com/llvm/llvm-project > f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6), LLD 10.0.1 > (https://github.com/llvm/llvm-project > f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6)) #2~bullseye+dileks1 SMP > 2020-05-20 > > I remember when I used official tarballs for RC releases, the version > string should look like: > > $ clang-10 --version > dileks clang version 10.0.1rc1Are you sure about this? I don't remember rc# being added to version strings, do you have an example of an older release build that does this? -Tom> Target: x86_64-unknown-linux-gnu > Thread model: posix > InstalledDir: /home/dileks/src/llvm-toolchain/install/bin > > $ ld.lld --version > LLD 10.0.1rc1 (compatible with GNU linkers) > > $ llvm-as --version > LLVM (http://llvm.org/): > LLVM version 10.0.1rc1 > Optimized build. > Default target: x86_64-unknown-linux-gnu > Host CPU: sandybridge > > My first change: > > [ llvm/CMakeLists.txt ] > > if(NOT DEFINED LLVM_VERSION_SUFFIX) > - set(LLVM_VERSION_SUFFIX "") > + set(LLVM_VERSION_SUFFIX "rc1") > endif() > > Unfortunately, clang-10 and ld.lld binaries did not show this in their version. > > So, I modified clang... > > [ clang/CMakeLists.txt ] > > -# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. > -set(CLANG_VERSION > "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") > +if(NOT DEFINED CLANG_VERSION_SUFFIX) > + set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) > +endif() > +# CLANG_VERSION includes LLVM_VERSION_SUFFIX. > +set(CLANG_VERSION > "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}") > > ...and lld (the same way clang handles its version): > > [ lld/CMakeLists.txt ] > > -# Compute the LLD version from the LLVM version. > -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLD_VERSION > - ${PACKAGE_VERSION}) > +# If LLD_VERSION_* is specified, use it, if not use LLVM_VERSION_*. > +if(NOT DEFINED LLD_VERSION_MAJOR) > + set(LLD_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) > +endif() > +if(NOT DEFINED LLD_VERSION_MINOR) > + set(LLD_VERSION_MINOR ${LLVM_VERSION_MINOR}) > +endif() > +if(NOT DEFINED LLD_VERSION_PATCHLEVEL) > + set(LLD_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) > +endif() > +if(NOT DEFINED LLD_VERSION_SUFFIX) > + set(LLD_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) > +endif() > +# LLD_VERSION includes LLVM_VERSION_SUFFIX. > +set(LLD_VERSION > "${LLD_VERSION_MAJOR}.${LLD_VERSION_MINOR}.${LLD_VERSION_PATCHLEVEL}${LLD_VERSION_SUFFIX}") > message(STATUS "LLD version: ${LLD_VERSION}") > > -string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" LLD_VERSION_MAJOR > - ${LLD_VERSION}) > -string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" LLD_VERSION_MINOR > - ${LLD_VERSION}) > - > > That worked like expected for clang-10 and ld.lld with "-v" and/or > "--version" options. > > A clang-test FAILED... Preprocessor/iwithprefix.c (below when using > LLVM_VERSION_SUFFIX = "git"): > > This is because of the "rc1" string in the include path ("git" accordingly): > > lib/clang/10.0.1rc1/include > > To fix this up (maybe someone can help to recognize "git" and "rc[1-9]"): > > [ clang/test/Preprocessor/iwithprefix.c ] > > -// CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}{{/|\\}}include > +// CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}rc1{{/|\\}}include > > I guess this is due to my introduction and usage of CLANG_VERSION_SUFFIX. > > Finally, I looked into master Git where I saw: > > if(NOT DEFINED LLVM_VERSION_SUFFIX) > set(LLVM_VERSION_SUFFIX "git") > endif() > > And re-checked every place where especially... > ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} > ...is used. > > So, I fixed it up by pre-checking for... if(LLVM_VERSION_SUFFIX STREQUAL "git") > > Example (full patch attached): > > [ llvm/cmake/modules/AddLLVM.cmake ] > > @@ -541,11 +541,18 @@ function(llvm_add_library name) > # Set SOVERSION on shared libraries that lack explicit SONAME > # specifier, on *nix systems that are not Darwin. > if(UNIX AND NOT APPLE AND NOT ARG_SONAME) > - set_target_properties(${name} > - PROPERTIES > - # Since 4.0.0, the ABI version is indicated by the major version > - SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} > - VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > + # Since 4.0.0, the ABI version is indicated by the major version > + if(LLVM_VERSION_SUFFIX STREQUAL "git") > + set_target_properties(${name} > + PROPERTIES > + SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} > + VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > + else() > + set_target_properties(${name} > + PROPERTIES > + SOVERSION ${LLVM_VERSION_MAJOR} > + VERSION ${LLVM_VERSION_MAJOR}) > + endif() > endif() > endif() > > @@ -567,8 +574,13 @@ function(llvm_add_library name) > if(${output_name} STREQUAL "output_name-NOTFOUND") > set(output_name ${name}) > endif() > - set(library_name > ${output_name}-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > - set(api_name > ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}) > + if(LLVM_VERSION_SUFFIX STREQUAL "git") > + set(library_name > ${output_name}-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > + set(api_name > ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}) > + else() > + set(library_name ${output_name}-${LLVM_VERSION_MAJOR}) > + set(api_name > ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}) > + endif() > set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name}) > llvm_install_library_symlink(${api_name} ${library_name} SHARED > > In the end I was able to build a LLVM/Clang/LLD toolchain which shows > me "10.0.1rc1" version string for all llvm-*, clang-10 and ld.lld > binaries. > > As I understand the llvm/stable maintainers do not use or bump > LLVM_VERSION_SUFFIX with RC releases as I have expected. > > But I see some problems when people do not use "git" as value in > LLVM_VERSION_SUFFIX - like me "rc1". > > Also, I see an inconsistency for llvm-* binaries when using "git" > whereas Clang and LLD do not show this in their version strings. > > I am not sure what the introduction of CLANG_VERSION_SUFFIX and > LLD_VERSION_SUFFIX is all doing. > > The only value used for LLVM_VERSION_SUFFIX is "git" in master Git branch. > > Where is LLVM_VERSION_SUFFIX really relevant? > What do you think of the usage of LLVM_VERSION_SUFFIX in general? > > What do you think to the changes to Clang and LLD versioning? > > Thanks. > > Regards, > - Sedat - > > P.S.: Some useful outputs > > FAIL: Clang :: Preprocessor/iwithprefix.c (8758 of 16586) > ******************** TEST 'Clang :: Preprocessor/iwithprefix.c' FAILED > ******************** > Script: > -- > : 'RUN: at line 3'; rm -rf > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps > : 'RUN: at line 4'; mkdir -p > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/first > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/second > : 'RUN: at line 5'; > /home/dileks/src/llvm-toolchain/build/stage1/bin/clang -cc1 > -internal-isystem > /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include > -nostdsysteminc -triple x86_64-unknown-unknown -iprefix > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/ > -iwithprefix second -isystem > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/first > -v /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c > 2> /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.out > : 'RUN: at line 8'; > /home/dileks/src/llvm-toolchain/build/stage1/bin/FileCheck > /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c > < /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.out > -- > Exit Code: 1 > > Command Output (stderr): > -- > /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c:12:11: > error: CHECK: expected string not found in input > // CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}{{/|\\}}include > ^ > <stdin>:6:2: note: scanning from here > /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include > ^ > <stdin>:6:45: note: possible intended match here > /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include > > [ scripts/run_tests_20200520.sh ] > > #!/bin/sh > > export LANG=C > export LC_ALL=C > > CLANG_TESTS="Preprocessor/iwithprefix.c" > > LLVM_LIT_OPTS="--verbose --echo-all-commands --show-all" > > cd build/stage1/ > > for t in $CLANG_TESTS ; do ./bin/llvm-lit $LLVM_LIT_OPTS > ./tools/clang/test/$t ; done > > - EOT - >
Sedat Dilek via llvm-dev
2020-May-22 04:50 UTC
[llvm-dev] Understanding the version handling in LLVM/Clang/LLD
On Thu, May 21, 2020 at 4:30 PM Tom Stellard <tstellar at redhat.com> wrote:> > On 05/21/2020 03:45 AM, Sedat Dilek wrote: > > [ Please CC me I ma not subcribed to this mailing-list ] > > > > [ CC Tom and Hans as LLVM/stable maintainers ] > > > > Hi, > > > > I want to understand the version handling in LLVM/Clang/LLD. > > > > Normally, I build from "release/10.x" Git branch by using the tool > > tc-build from ClangBuiltLinux project. > > > > With "llvm-10.0.1-rc1" Git tag I was able to setup a llvm-toolchain > > consisting of the projects "clang" and "lld". > > > > A Linux v5.7-rc6 was successfully built. > > > > $ cat /proc/version > > Linux version 5.7.0-rc6-2-amd64-clang (sedat.dilek at gmail.com@iniza) > > (ClangBuiltLinux clang version 10.0.1 > > (https://github.com/llvm/llvm-project > > f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6), LLD 10.0.1 > > (https://github.com/llvm/llvm-project > > f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6)) #2~bullseye+dileks1 SMP > > 2020-05-20 > > > > I remember when I used official tarballs for RC releases, the version > > string should look like: > > > > $ clang-10 --version > > dileks clang version 10.0.1rc1 > > Are you sure about this? I don't remember rc# being added to version > strings, do you have an example of an older release build that does this? >Hi Tom, yesterday morning I downloaded llvm-5.0.0rc5.src.tar.xz to check myself before you answered me: [ llvm-5.0.0rc5.src/CMakeLists.txt ] if(NOT DEFINED LLVM_VERSION_MAJOR) set(LLVM_VERSION_MAJOR 5) endif() if(NOT DEFINED LLVM_VERSION_MINOR) set(LLVM_VERSION_MINOR 0) endif() if(NOT DEFINED LLVM_VERSION_PATCH) set(LLVM_VERSION_PATCH 0) endif() if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX "") endif() "I am a bad liar..." (see [1]) or digital dementia :-)? I have to check my old build-script from my archived Ubuntu/precise 12.04 LTS system. Darkly I remember I played with some "program-suffix" options. I will report later. I will also double check some older binaries from <https://snapshot.debian.org/> to see if I recall correct and decide if I need a red or blue pill. Thanks for taking care! Regards, - Sedat - [1] https://www.youtube.com/watch?v=I-QfPUz1es8 [2] https://snapshot.debian.org/package/llvm-toolchain-3.6/> -Tom > > > Target: x86_64-unknown-linux-gnu > > Thread model: posix > > InstalledDir: /home/dileks/src/llvm-toolchain/install/bin > > > > $ ld.lld --version > > LLD 10.0.1rc1 (compatible with GNU linkers) > > > > $ llvm-as --version > > LLVM (http://llvm.org/): > > LLVM version 10.0.1rc1 > > Optimized build. > > Default target: x86_64-unknown-linux-gnu > > Host CPU: sandybridge > > > > My first change: > > > > [ llvm/CMakeLists.txt ] > > > > if(NOT DEFINED LLVM_VERSION_SUFFIX) > > - set(LLVM_VERSION_SUFFIX "") > > + set(LLVM_VERSION_SUFFIX "rc1") > > endif() > > > > Unfortunately, clang-10 and ld.lld binaries did not show this in their version. > > > > So, I modified clang... > > > > [ clang/CMakeLists.txt ] > > > > -# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. > > -set(CLANG_VERSION > > "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") > > +if(NOT DEFINED CLANG_VERSION_SUFFIX) > > + set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) > > +endif() > > +# CLANG_VERSION includes LLVM_VERSION_SUFFIX. > > +set(CLANG_VERSION > > "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}") > > > > ...and lld (the same way clang handles its version): > > > > [ lld/CMakeLists.txt ] > > > > -# Compute the LLD version from the LLVM version. > > -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLD_VERSION > > - ${PACKAGE_VERSION}) > > +# If LLD_VERSION_* is specified, use it, if not use LLVM_VERSION_*. > > +if(NOT DEFINED LLD_VERSION_MAJOR) > > + set(LLD_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) > > +endif() > > +if(NOT DEFINED LLD_VERSION_MINOR) > > + set(LLD_VERSION_MINOR ${LLVM_VERSION_MINOR}) > > +endif() > > +if(NOT DEFINED LLD_VERSION_PATCHLEVEL) > > + set(LLD_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) > > +endif() > > +if(NOT DEFINED LLD_VERSION_SUFFIX) > > + set(LLD_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX}) > > +endif() > > +# LLD_VERSION includes LLVM_VERSION_SUFFIX. > > +set(LLD_VERSION > > "${LLD_VERSION_MAJOR}.${LLD_VERSION_MINOR}.${LLD_VERSION_PATCHLEVEL}${LLD_VERSION_SUFFIX}") > > message(STATUS "LLD version: ${LLD_VERSION}") > > > > -string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" LLD_VERSION_MAJOR > > - ${LLD_VERSION}) > > -string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" LLD_VERSION_MINOR > > - ${LLD_VERSION}) > > - > > > > That worked like expected for clang-10 and ld.lld with "-v" and/or > > "--version" options. > > > > A clang-test FAILED... Preprocessor/iwithprefix.c (below when using > > LLVM_VERSION_SUFFIX = "git"): > > > > This is because of the "rc1" string in the include path ("git" accordingly): > > > > lib/clang/10.0.1rc1/include > > > > To fix this up (maybe someone can help to recognize "git" and "rc[1-9]"): > > > > [ clang/test/Preprocessor/iwithprefix.c ] > > > > -// CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}{{/|\\}}include > > +// CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}rc1{{/|\\}}include > > > > I guess this is due to my introduction and usage of CLANG_VERSION_SUFFIX. > > > > Finally, I looked into master Git where I saw: > > > > if(NOT DEFINED LLVM_VERSION_SUFFIX) > > set(LLVM_VERSION_SUFFIX "git") > > endif() > > > > And re-checked every place where especially... > > ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} > > ...is used. > > > > So, I fixed it up by pre-checking for... if(LLVM_VERSION_SUFFIX STREQUAL "git") > > > > Example (full patch attached): > > > > [ llvm/cmake/modules/AddLLVM.cmake ] > > > > @@ -541,11 +541,18 @@ function(llvm_add_library name) > > # Set SOVERSION on shared libraries that lack explicit SONAME > > # specifier, on *nix systems that are not Darwin. > > if(UNIX AND NOT APPLE AND NOT ARG_SONAME) > > - set_target_properties(${name} > > - PROPERTIES > > - # Since 4.0.0, the ABI version is indicated by the major version > > - SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} > > - VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > > + # Since 4.0.0, the ABI version is indicated by the major version > > + if(LLVM_VERSION_SUFFIX STREQUAL "git") > > + set_target_properties(${name} > > + PROPERTIES > > + SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} > > + VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > > + else() > > + set_target_properties(${name} > > + PROPERTIES > > + SOVERSION ${LLVM_VERSION_MAJOR} > > + VERSION ${LLVM_VERSION_MAJOR}) > > + endif() > > endif() > > endif() > > > > @@ -567,8 +574,13 @@ function(llvm_add_library name) > > if(${output_name} STREQUAL "output_name-NOTFOUND") > > set(output_name ${name}) > > endif() > > - set(library_name > > ${output_name}-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > > - set(api_name > > ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}) > > + if(LLVM_VERSION_SUFFIX STREQUAL "git") > > + set(library_name > > ${output_name}-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}) > > + set(api_name > > ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}) > > + else() > > + set(library_name ${output_name}-${LLVM_VERSION_MAJOR}) > > + set(api_name > > ${output_name}-${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}) > > + endif() > > set_target_properties(${name} PROPERTIES OUTPUT_NAME ${library_name}) > > llvm_install_library_symlink(${api_name} ${library_name} SHARED > > > > In the end I was able to build a LLVM/Clang/LLD toolchain which shows > > me "10.0.1rc1" version string for all llvm-*, clang-10 and ld.lld > > binaries. > > > > As I understand the llvm/stable maintainers do not use or bump > > LLVM_VERSION_SUFFIX with RC releases as I have expected. > > > > But I see some problems when people do not use "git" as value in > > LLVM_VERSION_SUFFIX - like me "rc1". > > > > Also, I see an inconsistency for llvm-* binaries when using "git" > > whereas Clang and LLD do not show this in their version strings. > > > > I am not sure what the introduction of CLANG_VERSION_SUFFIX and > > LLD_VERSION_SUFFIX is all doing. > > > > The only value used for LLVM_VERSION_SUFFIX is "git" in master Git branch. > > > > Where is LLVM_VERSION_SUFFIX really relevant? > > What do you think of the usage of LLVM_VERSION_SUFFIX in general? > > > > What do you think to the changes to Clang and LLD versioning? > > > > Thanks. > > > > Regards, > > - Sedat - > > > > P.S.: Some useful outputs > > > > FAIL: Clang :: Preprocessor/iwithprefix.c (8758 of 16586) > > ******************** TEST 'Clang :: Preprocessor/iwithprefix.c' FAILED > > ******************** > > Script: > > -- > > : 'RUN: at line 3'; rm -rf > > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps > > : 'RUN: at line 4'; mkdir -p > > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/first > > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/second > > : 'RUN: at line 5'; > > /home/dileks/src/llvm-toolchain/build/stage1/bin/clang -cc1 > > -internal-isystem > > /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include > > -nostdsysteminc -triple x86_64-unknown-unknown -iprefix > > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/ > > -iwithprefix second -isystem > > /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.tmps/first > > -v /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c > > 2> /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.out > > : 'RUN: at line 8'; > > /home/dileks/src/llvm-toolchain/build/stage1/bin/FileCheck > > /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c > > < /home/dileks/src/llvm-toolchain/build/stage1/tools/clang/test/Preprocessor/Output/iwithprefix.c.tmp.out > > -- > > Exit Code: 1 > > > > Command Output (stderr): > > -- > > /home/dileks/src/llvm-toolchain/tc-build/llvm-project/clang/test/Preprocessor/iwithprefix.c:12:11: > > error: CHECK: expected string not found in input > > // CHECK: {{/|\\}}lib{{(32|64)?}}{{/|\\}}clang{{/|\\}}{{[.0-9]+}}{{/|\\}}include > > ^ > > <stdin>:6:2: note: scanning from here > > /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include > > ^ > > <stdin>:6:45: note: possible intended match here > > /home/dileks/src/llvm-toolchain/build/stage1/lib/clang/10.0.1git/include > > > > [ scripts/run_tests_20200520.sh ] > > > > #!/bin/sh > > > > export LANG=C > > export LC_ALL=C > > > > CLANG_TESTS="Preprocessor/iwithprefix.c" > > > > LLVM_LIT_OPTS="--verbose --echo-all-commands --show-all" > > > > cd build/stage1/ > > > > for t in $CLANG_TESTS ; do ./bin/llvm-lit $LLVM_LIT_OPTS > > ./tools/clang/test/$t ; done > > > > - EOT - > > >
Sedat Dilek via llvm-dev
2020-May-22 14:27 UTC
[llvm-dev] Understanding the version handling in LLVM/Clang/LLD
With my modifications I was able to build and boot a Linux v5.7-rc6+ kernel on Debian/testing AMD64. root at iniza:~# cat /proc/version Linux version 5.7.0-rc6-4-amd64-clang (sedat.dilek at gmail.com@iniza) (clang version 10.0.1rc1, LLD 10.0.1rc1) #4~bullseye+dileks1 SMP 2020-05-22 - Sedat -
Sedat Dilek via llvm-dev
2020-May-27 16:13 UTC
[llvm-dev] Understanding the version handling in LLVM/Clang/LLD
I have downloaded the llvm-toolchain from [1]: dileks at iniza:~/src/llvm-toolchain/clang+llvm-10.0.1-rc1-x86_64-pc-linux-gnu/bin$ ./clang-10 -v clang version 10.0.1 (https://github.com/llvm/llvm-project.git 01636c1eeace5371fef8508c7318df9d7a25b489) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/dileks/src/llvm-toolchain/clang+llvm-10.0.1-rc1-x86_64-pc-linux-gnu/bin/. Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64 dileks at iniza:~/src/llvm-toolchain/clang+llvm-10.0.1-rc1-x86_64-pc-linux-gnu/bin$ ./ld.lld -v LLD 10.0.1 (https://github.com/llvm/llvm-project.git 01636c1eeace5371fef8508c7318df9d7a25b489) (compatible with GNU linkers) What is that for a commit-hash-id? Even on master Git branch: $ git describe --contains 01636c1eeace5371fef8508c7318df9d7a25b489 fatal: cannot describe '01636c1eeace5371fef8508c7318df9d7a25b489' $ git describe --contains f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6 llvmorg-10.0.1-rc1 Last commit in release/10.x before llvmorg-10.0.1-rc1 was tagged: "[arm] Add big-endian version of pcrel fixups for adr instructions" Commit-hash-id of the tag? - Sedat - [1] https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1-rc1/clang+llvm-10.0.1-rc1-x86_64-pc-linux-gnu.tar.xz [2] https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1-rc1/clang+llvm-10.0.1-rc1-x86_64-pc-linux-gnu.tar.xz.sig [3] https://github.com/llvm/llvm-project/commit/f79cd71e145c6fd005ba4dd1238128dfa0dc2cb6
Seemingly Similar Threads
- 10.0.1-rc1 release has been tagged
- 10.0.1-rc1 release has been tagged
- 10.0.1-rc1 release has been tagged
- [LLVMdev] [PATCH] CMake: Use LLVM_VERSION_SUFFIX instead of hardcoded "svn" string
- [LLVMdev] [PATCH] CMake: Use LLVM_VERSION_SUFFIX instead of hardcoded "svn" string