Skip to content

Commit cc2b432

Browse files
authored
[Clang][Cmake] fix libtool duplicate member name warnings (#133619)
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 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 #132252 (comment). 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 this in compiler-rt and test directories so assumed there was a reason it wasn't used.
1 parent 5877bef commit cc2b432

File tree

4 files changed

+67
-38
lines changed

4 files changed

+67
-38
lines changed

clang/lib/CodeGen/CMakeLists.txt

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -116,45 +116,8 @@ add_clang_library(clangCodeGen
116116
PatternInit.cpp
117117
SanitizerMetadata.cpp
118118
SwiftCallingConv.cpp
119-
TargetBuiltins/ARM.cpp
120-
TargetBuiltins/AMDGPU.cpp
121-
TargetBuiltins/Hexagon.cpp
122-
TargetBuiltins/NVPTX.cpp
123-
TargetBuiltins/PPC.cpp
124-
TargetBuiltins/RISCV.cpp
125-
TargetBuiltins/SPIR.cpp
126-
TargetBuiltins/SystemZ.cpp
127-
TargetBuiltins/WebAssembly.cpp
128-
TargetBuiltins/X86.cpp
129119
TargetInfo.cpp
130-
Targets/AArch64.cpp
131-
Targets/AMDGPU.cpp
132-
Targets/ARC.cpp
133-
Targets/ARM.cpp
134-
Targets/AVR.cpp
135-
Targets/BPF.cpp
136-
Targets/CSKY.cpp
137-
Targets/DirectX.cpp
138-
Targets/Hexagon.cpp
139-
Targets/Lanai.cpp
140-
Targets/LoongArch.cpp
141-
Targets/M68k.cpp
142-
Targets/MSP430.cpp
143-
Targets/Mips.cpp
144-
Targets/NVPTX.cpp
145-
Targets/PNaCl.cpp
146-
Targets/PPC.cpp
147-
Targets/RISCV.cpp
148-
Targets/SPIR.cpp
149-
Targets/Sparc.cpp
150-
Targets/SystemZ.cpp
151-
Targets/TCE.cpp
152-
Targets/VE.cpp
153-
Targets/WebAssembly.cpp
154-
Targets/X86.cpp
155-
Targets/XCore.cpp
156120
VarBypassDetector.cpp
157-
158121
DEPENDS
159122
vt_gen
160123
intrinsics_gen
@@ -170,4 +133,16 @@ add_clang_library(clangCodeGen
170133
clangFrontend
171134
clangLex
172135
clangSerialization
136+
clangCodeGenTargetBuiltins
137+
clangCodeGenTargets
138+
)
139+
140+
target_include_directories(clangCodeGen
141+
PUBLIC
142+
${CMAKE_CURRENT_SOURCE_DIR}
143+
${CMAKE_CURRENT_SOURCE_DIR}/TargetBuiltins
144+
${CMAKE_CURRENT_SOURCE_DIR}/Targets
173145
)
146+
147+
add_subdirectory(TargetBuiltins)
148+
add_subdirectory(Targets)

clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===------- AMDCPU.cpp - Emit LLVM Code for builtins ---------------------===//
1+
//===------- AMDGPU.cpp - Emit LLVM Code for builtins ---------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
2+
3+
add_clang_library(clangCodeGenTargetBuiltins STATIC
4+
ARM.cpp
5+
AMDGPU.cpp
6+
Hexagon.cpp
7+
NVPTX.cpp
8+
PPC.cpp
9+
RISCV.cpp
10+
SPIR.cpp
11+
SystemZ.cpp
12+
WebAssembly.cpp
13+
X86.cpp
14+
)
15+
16+
target_link_libraries(clangCodeGenTargetBuiltins
17+
PRIVATE
18+
clangCodeGen
19+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
2+
3+
add_clang_library(clangCodeGenTargets STATIC
4+
AArch64.cpp
5+
AMDGPU.cpp
6+
ARC.cpp
7+
ARM.cpp
8+
AVR.cpp
9+
BPF.cpp
10+
CSKY.cpp
11+
DirectX.cpp
12+
Hexagon.cpp
13+
Lanai.cpp
14+
LoongArch.cpp
15+
M68k.cpp
16+
MSP430.cpp
17+
Mips.cpp
18+
NVPTX.cpp
19+
PNaCl.cpp
20+
PPC.cpp
21+
RISCV.cpp
22+
SPIR.cpp
23+
Sparc.cpp
24+
SystemZ.cpp
25+
TCE.cpp
26+
VE.cpp
27+
WebAssembly.cpp
28+
X86.cpp
29+
XCore.cpp
30+
)
31+
32+
target_link_libraries(clangCodeGenTargets
33+
PRIVATE
34+
clangCodeGen
35+
)

0 commit comments

Comments
 (0)