Skip to content
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

LLVM / Clang library names have git in the filenames libclang.so.15.0.0git / libLTO.so.15git / libclang-cpp.so.15git / libRemarks.so.15git #53932

Open
brad0 opened this issue Feb 18, 2022 · 14 comments
Assignees
Labels
clang Clang issues not falling into any other category cmake Build system in general and CMake in particular

Comments

@brad0
Copy link
Contributor

brad0 commented Feb 18, 2022

I can't seem to find how to get rid of the git bit at the end of the library name. This is breaking linking.

@EugeneZelenko EugeneZelenko added clang Clang issues not falling into any other category cmake Build system in general and CMake in particular and removed new issue labels Feb 18, 2022
@brad0
Copy link
Contributor Author

brad0 commented Feb 20, 2022

Still looking for assistance with this. If I build the 14 branch for example that does not put git in the filename it builds fine.

@tstellar
Copy link
Collaborator

I will take a look at this.

@brad0
Copy link
Contributor Author

brad0 commented Apr 16, 2022

Grep'ing around a bit to try and figure out where this comes from I came across...

llvm/CMakeLists.txt

if(NOT DEFINED LLVM_VERSION_SUFFIX)
  set(LLVM_VERSION_SUFFIX git)
endif()

if (NOT PACKAGE_VERSION)
  set(PACKAGE_VERSION
    "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")
endif()

clang/tools/libclang

    set_target_properties(libclang PROPERTIES
                          VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}
                          SOVERSION ${CLANG_SONAME})

llvm/cmake/modules/AddLLVM.cmake

    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})
    endif()

llvm/tools/llvm-config/CMakeLists.txt

set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}")

and saw this commit on the 14 branch... 8d3c673

That fixes the generated library name via CMake. Including LLVM_VERSION_SUFFIX in the version string is fine if building this into a binary (.e.g. clang -v) but not for forming the shared library name and specifically the version part of the name.

@brad0 brad0 changed the title Clang library name has git in the filename libclang.so.15.0.0git LLVM / Clang library names have git in the filenames libclang.so.15.0.0git / libLTO.so.15git / libclang-cpp.so.15git / libRemarks.so.15git Apr 16, 2022
@brad0
Copy link
Contributor Author

brad0 commented Apr 16, 2022

diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 4e0647971ab4..ea5e458f3fde 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -178,7 +178,7 @@ if(ENABLE_SHARED)
                  OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libclang.map)

     set_target_properties(libclang PROPERTIES
-                          VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}
+                          VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}
                           SOVERSION ${CLANG_SONAME})
   endif()
 endif()
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 0e20b613afd9..dabf16df469f 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -603,8 +603,8 @@ function(llvm_add_library name)
       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})
+        SOVERSION ${LLVM_VERSION_MAJOR}
+        VERSION ${LLVM_VERSION_MAJOR})
     endif()
   endif()

diff --git a/llvm/tools/llvm-config/CMakeLists.txt b/llvm/tools/llvm-config/CMakeLists.txt
index aa5aa20257f9..cd45e090e055 100644
--- a/llvm/tools/llvm-config/CMakeLists.txt
+++ b/llvm/tools/llvm-config/CMakeLists.txt
@@ -55,7 +55,7 @@ set(LLVM_CFLAGS "${LLVM_C_STD_FLAG} ${LLVM_DEFINITIONS}")
 set(LLVM_CXXFLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION} ${LLVM_CXX_STDLIB_FLAG} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
 set(LLVM_BUILD_SYSTEM cmake)
 set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI})
-set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}")
+set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}")

 # Use the C++ link flags, since they should be a superset of C link flags.
 set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}")

@brad0
Copy link
Contributor Author

brad0 commented Apr 25, 2022

@tstellar ?

@tstellar
Copy link
Collaborator

Is this a regression. I thought it was always like this?

@Sofianebouaziz1
Copy link

Please, how did you fix it ? I'm facing the same problem

@brad0
Copy link
Contributor Author

brad0 commented Apr 28, 2022

Please, how did you fix it ? I'm facing the same problem

The diff I posted above eliminates the suffix from the created libraries / plugins.

fubar$ bin/llvm-ar --version
LLVM (http://llvm.org/):
  LLVM version 15.0.0git
  Optimized build with assertions.
  Default target: amd64-unknown-openbsd7.0
  Host CPU: skylake
fubar$ find . -name '*.so.*' -print
./lib/libRemarks.so.15
./lib/libclang.so.15.0.0
./lib/libLTO.so.15
./lib/libclang-cpp.so.15
./lib/libclang.so.13

@brad0
Copy link
Contributor Author

brad0 commented Apr 28, 2022

Is this a regression. I thought it was always like this?

I rarely do builds from git. Most of the time it is against releases plus patches or maybe release branches which have suffix disabled. But I honestly believe there was a time the tree built without me having to patch anything.

@brad0
Copy link
Contributor Author

brad0 commented Jul 6, 2022

@tstellar ?

@tstellar
Copy link
Collaborator

tstellar commented Jul 6, 2022

@brad0 What does your link command look like? There are symlinks without the git suffix e.g.

libLTO.so.15git
libLTO.so -> libLTO.so.15git
libclang-cpp.so.15git
libclang-cpp.so -> libclang-cpp.so.15git
libclang.so.15
libclang.so.15git -> libclang.so.15
libclang.so -> libclang.so.15git

@brad0
Copy link
Contributor Author

brad0 commented Jul 26, 2022

OpenBSD doesn't handle shared libs quite in the same manner as other ELF OS's like FreeBSD/NetBSD/Linux/Solaris.

libLTO.so -> libLTO.so.15
libLTO.so.15
libclang-cpp.so -> libclang-cpp.so.15
libclang-cpp.so.15
libclang.so -> libclang.so.13
libclang.so.13 -> libclang.so.15.0.0
libclang.so.15.0.0

Is what is created minus the git suffix. The various libraries would have been crated with the git suffix if it were able to complete linking. OpenBSD doesn't use the .so sym-links. Nor would the old 13 ABI sym-link.

@tstellar
Copy link
Collaborator

@brad0 I don't follow this, what exactly does OpenBSD do differently?

@brad0
Copy link
Contributor Author

brad0 commented Nov 18, 2022

No symlinks for shared libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category cmake Build system in general and CMake in particular
Projects
None yet
Development

No branches or pull requests

4 participants