[clang] Reland [Clang][Cmake] fix libtool duplicate member name warnings (PR #133850)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 31 21:14:28 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Farzon Lotfi (farzonl)
<details>
<summary>Changes</summary>
fixes https://github.com/llvm/llvm-project/issues/133199
The fix to reland was moving `Targets/DirectX.cpp` from `clang/lib/CodeGen/Targets/CMakeLists.txt` back to `clang/lib/CodeGen/CMakeLists.txt`.
That change means that the files in `clang/lib/CodeGen/Targets/CMakeLists.txt` needs to be marked `PARTIAL_SOURCES_INTENDED`.
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 is to seperate the cmake files into their own sub directories as static libs.
---
Full diff: https://github.com/llvm/llvm-project/pull/133850.diff
4 Files Affected:
- (modified) clang/lib/CodeGen/CMakeLists.txt (+13-36)
- (modified) clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp (+1-1)
- (added) clang/lib/CodeGen/TargetBuiltins/CMakeLists.txt (+14)
- (added) clang/lib/CodeGen/Targets/CMakeLists.txt (+30)
``````````diff
diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index ebe2fbd7db295..2bf32a6b9d8aa 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -116,45 +116,10 @@ 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 +135,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..531a9461b7201
--- /dev/null
+++ b/clang/lib/CodeGen/Targets/CMakeLists.txt
@@ -0,0 +1,30 @@
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+add_clang_library(clangCodeGenTargets STATIC
+ PARTIAL_SOURCES_INTENDED
+ AArch64.cpp
+ AMDGPU.cpp
+ ARC.cpp
+ ARM.cpp
+ AVR.cpp
+ BPF.cpp
+ CSKY.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
+)
``````````
</details>
https://github.com/llvm/llvm-project/pull/133850
More information about the cfe-commits
mailing list