[clang] Reland [Clang][Cmake] fix libtool duplicate member name warnings (PR #133850)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 2 14:59:16 PDT 2025
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/133850
>From ac51727e83539ce998e32465665bb87b3ee7ed00 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi <farzonlotfi at 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 22551e6f46666e73d4fd99cf1c5313d0a7851806 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi <farzonlotfi at microsoft.com>
Date: Mon, 31 Mar 2025 23:40:32 -0400
Subject: [PATCH 2/3] DirectX use of HLSLBufferLayoutBuilder inside of
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..bc731af8a4eec 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 e6ec9a3a8bfe07b3b4ecdb35bab6f45590ed39a4 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi <farzonlotfi at microsoft.com>
Date: Wed, 2 Apr 2025 17:58:11 -0400
Subject: [PATCH 3/3] moving HLSLBufferLayoutBuilder.cpp from clang/lib/CodeGen
to clang/lib/CodeGen/Targets fixes things so we don't need
PARTIAL_SOURCES_INTENDED and don't need to special case into the
clangcodegen library
---
clang/lib/CodeGen/CMakeLists.txt | 2 --
clang/lib/CodeGen/Targets/CMakeLists.txt | 3 ++-
clang/lib/CodeGen/{ => Targets}/HLSLBufferLayoutBuilder.cpp | 0
3 files changed, 2 insertions(+), 3 deletions(-)
rename clang/lib/CodeGen/{ => Targets}/HLSLBufferLayoutBuilder.cpp (100%)
diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index bc731af8a4eec..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
@@ -117,7 +116,6 @@ add_clang_library(clangCodeGen
SanitizerMetadata.cpp
SwiftCallingConv.cpp
TargetInfo.cpp
- Targets/DirectX.cpp
VarBypassDetector.cpp
DEPENDS
diff --git a/clang/lib/CodeGen/Targets/CMakeLists.txt b/clang/lib/CodeGen/Targets/CMakeLists.txt
index 531a9461b7201..6cf4167e2cda2 100644
--- a/clang/lib/CodeGen/Targets/CMakeLists.txt
+++ b/clang/lib/CodeGen/Targets/CMakeLists.txt
@@ -1,7 +1,6 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
add_clang_library(clangCodeGenTargets STATIC
- PARTIAL_SOURCES_INTENDED
AArch64.cpp
AMDGPU.cpp
ARC.cpp
@@ -9,6 +8,8 @@ add_clang_library(clangCodeGenTargets STATIC
AVR.cpp
BPF.cpp
CSKY.cpp
+ DirectX.cpp
+ HLSLBufferLayoutBuilder.cpp
Hexagon.cpp
Lanai.cpp
LoongArch.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
More information about the cfe-commits
mailing list