https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/133850
>From a3c7c5b35bd48acb49666cdec410a6a31b14941f Mon Sep 17 00:00:00 2001 From: Farzon Lotfi <farzonlo...@microsoft.com> Date: Sun, 30 Mar 2025 00:59:48 -0400 Subject: [PATCH 1/3] [Clang][Cmake] fix libtool duplicate member name warnings fixes #133199 PR #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 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 is to seperate the cmake files into their own sub directories. I chose to create static libraries. It might of been possible to build an OBJECT, but I only saw examples of $<TARGET_OBJECTS:> in compiler-rt and test directories so assumed there was a reason it wasn't used. --- clang/lib/CodeGen/CMakeLists.txt | 49 +++++-------------- clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp | 2 +- .../lib/CodeGen/TargetBuiltins/CMakeLists.txt | 14 ++++++ clang/lib/CodeGen/Targets/CMakeLists.txt | 30 ++++++++++++ 4 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 clang/lib/CodeGen/TargetBuiltins/CMakeLists.txt create mode 100644 clang/lib/CodeGen/Targets/CMakeLists.txt diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt index ebe2fbd7db295..cdf9f909a3675 100644 --- a/clang/lib/CodeGen/CMakeLists.txt +++ b/clang/lib/CodeGen/CMakeLists.txt @@ -116,45 +116,8 @@ 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 vt_gen intrinsics_gen @@ -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..6b6e7ce5b0b29 --- /dev/null +++ b/clang/lib/CodeGen/Targets/CMakeLists.txt @@ -0,0 +1,30 @@ +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 + 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 +) >From c3064286b3ce53b883e271c1f52290eeb52bc229 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi <farzonlo...@microsoft.com> Date: Mon, 31 Mar 2025 23:40:32 -0400 Subject: [PATCH 2/3] DirectX use of CodeGenModule as input to getHLSLType makes it so it has to be compiled in clang/lib/CodeGen/CMakeLists.txt. This means clangCodeGenTargets needs to be PARTIAL_SOURCES_INTENDED. or clang/lib/CodeGen/Targets/DirectX.cpp needs to be moved to a different directory. --- clang/lib/CodeGen/CMakeLists.txt | 2 ++ clang/lib/CodeGen/Targets/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt index cdf9f909a3675..2bf32a6b9d8aa 100644 --- a/clang/lib/CodeGen/CMakeLists.txt +++ b/clang/lib/CodeGen/CMakeLists.txt @@ -117,7 +117,9 @@ add_clang_library(clangCodeGen SanitizerMetadata.cpp SwiftCallingConv.cpp TargetInfo.cpp + Targets/DirectX.cpp VarBypassDetector.cpp + DEPENDS vt_gen intrinsics_gen diff --git a/clang/lib/CodeGen/Targets/CMakeLists.txt b/clang/lib/CodeGen/Targets/CMakeLists.txt index 6b6e7ce5b0b29..531a9461b7201 100644 --- a/clang/lib/CodeGen/Targets/CMakeLists.txt +++ b/clang/lib/CodeGen/Targets/CMakeLists.txt @@ -1,6 +1,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) add_clang_library(clangCodeGenTargets STATIC + PARTIAL_SOURCES_INTENDED AArch64.cpp AMDGPU.cpp ARC.cpp @@ -8,7 +9,6 @@ add_clang_library(clangCodeGenTargets STATIC AVR.cpp BPF.cpp CSKY.cpp - DirectX.cpp Hexagon.cpp Lanai.cpp LoongArch.cpp >From d00d2468159f2d05ac0f9c885621ef01054d7734 Mon Sep 17 00:00:00 2001 From: Farzon Lotfi <farzonlo...@microsoft.com> Date: Tue, 1 Apr 2025 02:28:12 -0400 Subject: [PATCH 3/3] remove space --- clang/lib/CodeGen/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt index 2bf32a6b9d8aa..bc731af8a4eec 100644 --- a/clang/lib/CodeGen/CMakeLists.txt +++ b/clang/lib/CodeGen/CMakeLists.txt @@ -119,7 +119,7 @@ add_clang_library(clangCodeGen TargetInfo.cpp Targets/DirectX.cpp VarBypassDetector.cpp - + DEPENDS vt_gen intrinsics_gen _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits