Author: Farzon Lotfi Date: 2025-04-07T09:53:07-04:00 New Revision: 0d71d9ab28d626e85a0085a50ff634f76a950ce0
URL: https://github.com/llvm/llvm-project/commit/0d71d9ab28d626e85a0085a50ff634f76a950ce0 DIFF: https://github.com/llvm/llvm-project/commit/0d71d9ab28d626e85a0085a50ff634f76a950ce0.diff LOG: Reland [Clang][Cmake] fix libtool duplicate member name warnings (#133850) fixes https://github.com/llvm/llvm-project/issues/133199 As of the third commit the fix to the linker missing references in `Targets/DirectX.cpp` found in https://github.com/llvm/llvm-project/pull/133776 was fixed by moving `HLSLBufferLayoutBuilder.cpp` to `clang/lib/CodeGen/Targets/`. It fixes the circular reference issue found in https://github.com/llvm/llvm-project/pull/133619 for all `-DBUILD_SHARED_LIBS=ON` builds by removing `target_link_libraries` from the sub directory cmake files. testing for amdgpu offload was done via `cmake -B ../llvm_amdgpu -S llvm -GNinja -C offload/cmake/caches/Offload.cmake -DCMAKE_BUILD_TYPE=Release` PR https://github.com/llvm/llvm-project/pull/132252 Created a second file that shared <TargetName>.cpp in clang/lib/CodeGen/CMakeLists.txt For example There were two AMDGPU.cpp's one in TargetBuiltins and the other in Targets. Even though these were in different directories libtool warns that it might not distinguish them because they share the same base name. There are two potential fixes. The easy fix is to rename one of them and keep one cmake file. That solution though doesn't future proof this problem in the event of a third <TargetName>.cpp and it seems teams want to just use the target name https://github.com/llvm/llvm-project/pull/132252#issuecomment-2758178483. The alternative fix that this PR went with is to seperate the cmake files into their own sub directories as static libs. Added: clang/lib/CodeGen/TargetBuiltins/CMakeLists.txt clang/lib/CodeGen/Targets/CMakeLists.txt clang/lib/CodeGen/Targets/HLSLBufferLayoutBuilder.cpp Modified: clang/lib/CodeGen/CMakeLists.txt clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp Removed: clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp ################################################################################ diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt index ebe2fbd7db295..7c627fc1cdb57 100644 --- a/clang/lib/CodeGen/CMakeLists.txt +++ b/clang/lib/CodeGen/CMakeLists.txt @@ -107,7 +107,6 @@ add_clang_library(clangCodeGen ConstantInitBuilder.cpp CoverageMappingGen.cpp ItaniumCXXABI.cpp - HLSLBufferLayoutBuilder.cpp LinkInModulesPass.cpp MacroPPCallbacks.cpp MicrosoftCXXABI.cpp @@ -116,43 +115,7 @@ add_clang_library(clangCodeGen PatternInit.cpp SanitizerMetadata.cpp SwiftCallingConv.cpp - TargetBuiltins/ARM.cpp - TargetBuiltins/AMDGPU.cpp - TargetBuiltins/Hexagon.cpp - TargetBuiltins/NVPTX.cpp - TargetBuiltins/PPC.cpp - TargetBuiltins/RISCV.cpp - TargetBuiltins/SPIR.cpp - TargetBuiltins/SystemZ.cpp - TargetBuiltins/WebAssembly.cpp - TargetBuiltins/X86.cpp TargetInfo.cpp - Targets/AArch64.cpp - Targets/AMDGPU.cpp - Targets/ARC.cpp - Targets/ARM.cpp - Targets/AVR.cpp - Targets/BPF.cpp - Targets/CSKY.cpp - Targets/DirectX.cpp - Targets/Hexagon.cpp - Targets/Lanai.cpp - Targets/LoongArch.cpp - Targets/M68k.cpp - Targets/MSP430.cpp - Targets/Mips.cpp - Targets/NVPTX.cpp - Targets/PNaCl.cpp - Targets/PPC.cpp - Targets/RISCV.cpp - Targets/SPIR.cpp - Targets/Sparc.cpp - Targets/SystemZ.cpp - Targets/TCE.cpp - Targets/VE.cpp - Targets/WebAssembly.cpp - Targets/X86.cpp - Targets/XCore.cpp VarBypassDetector.cpp DEPENDS @@ -170,4 +133,16 @@ add_clang_library(clangCodeGen clangFrontend clangLex clangSerialization + clangCodeGenTargetBuiltins + clangCodeGenTargets ) + + target_include_directories(clangCodeGen + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/TargetBuiltins + ${CMAKE_CURRENT_SOURCE_DIR}/Targets + ) + + add_subdirectory(TargetBuiltins) + add_subdirectory(Targets) diff --git a/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp b/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp index b56b739094ff3..577fee05d4af6 100644 --- a/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp +++ b/clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp @@ -1,4 +1,4 @@ -//===------- AMDCPU.cpp - Emit LLVM Code for builtins ---------------------===// +//===------- AMDGPU.cpp - Emit LLVM Code for builtins ---------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/clang/lib/CodeGen/TargetBuiltins/CMakeLists.txt b/clang/lib/CodeGen/TargetBuiltins/CMakeLists.txt new file mode 100644 index 0000000000000..76be68a11d02a --- /dev/null +++ b/clang/lib/CodeGen/TargetBuiltins/CMakeLists.txt @@ -0,0 +1,14 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + +add_clang_library(clangCodeGenTargetBuiltins STATIC + ARM.cpp + AMDGPU.cpp + Hexagon.cpp + NVPTX.cpp + PPC.cpp + RISCV.cpp + SPIR.cpp + SystemZ.cpp + WebAssembly.cpp + X86.cpp +) diff --git a/clang/lib/CodeGen/Targets/CMakeLists.txt b/clang/lib/CodeGen/Targets/CMakeLists.txt new file mode 100644 index 0000000000000..6cf4167e2cda2 --- /dev/null +++ b/clang/lib/CodeGen/Targets/CMakeLists.txt @@ -0,0 +1,31 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + +add_clang_library(clangCodeGenTargets STATIC + AArch64.cpp + AMDGPU.cpp + ARC.cpp + ARM.cpp + AVR.cpp + BPF.cpp + CSKY.cpp + DirectX.cpp + HLSLBufferLayoutBuilder.cpp + Hexagon.cpp + Lanai.cpp + LoongArch.cpp + M68k.cpp + MSP430.cpp + Mips.cpp + NVPTX.cpp + PNaCl.cpp + PPC.cpp + RISCV.cpp + SPIR.cpp + Sparc.cpp + SystemZ.cpp + TCE.cpp + VE.cpp + WebAssembly.cpp + X86.cpp + XCore.cpp +) diff --git a/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp b/clang/lib/CodeGen/Targets/HLSLBufferLayoutBuilder.cpp similarity index 100% rename from clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp rename to clang/lib/CodeGen/Targets/HLSLBufferLayoutBuilder.cpp _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits