Skip to content

Commit 0d71d9a

Browse files
authored
Reland [Clang][Cmake] fix libtool duplicate member name warnings (#133850)
fixes #133199 As of the third commit the fix to the linker missing references in `Targets/DirectX.cpp` found in #133776 was fixed by moving `HLSLBufferLayoutBuilder.cpp` to `clang/lib/CodeGen/Targets/`. It fixes the circular reference issue found in #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 #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 that this PR went with is to seperate the cmake files into their own sub directories as static libs.
1 parent b2711e1 commit 0d71d9a

File tree

5 files changed

+58
-38
lines changed

5 files changed

+58
-38
lines changed

Diff for: clang/lib/CodeGen/CMakeLists.txt

+12-37
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ add_clang_library(clangCodeGen
107107
ConstantInitBuilder.cpp
108108
CoverageMappingGen.cpp
109109
ItaniumCXXABI.cpp
110-
HLSLBufferLayoutBuilder.cpp
111110
LinkInModulesPass.cpp
112111
MacroPPCallbacks.cpp
113112
MicrosoftCXXABI.cpp
@@ -116,43 +115,7 @@ add_clang_library(clangCodeGen
116115
PatternInit.cpp
117116
SanitizerMetadata.cpp
118117
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
129118
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
156119
VarBypassDetector.cpp
157120

158121
DEPENDS
@@ -170,4 +133,16 @@ add_clang_library(clangCodeGen
170133
clangFrontend
171134
clangLex
172135
clangSerialization
136+
clangCodeGenTargetBuiltins
137+
clangCodeGenTargets
173138
)
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
145+
)
146+
147+
add_subdirectory(TargetBuiltins)
148+
add_subdirectory(Targets)

Diff for: clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

+1-1
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.

Diff for: clang/lib/CodeGen/TargetBuiltins/CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
)

Diff for: clang/lib/CodeGen/Targets/CMakeLists.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
HLSLBufferLayoutBuilder.cpp
13+
Hexagon.cpp
14+
Lanai.cpp
15+
LoongArch.cpp
16+
M68k.cpp
17+
MSP430.cpp
18+
Mips.cpp
19+
NVPTX.cpp
20+
PNaCl.cpp
21+
PPC.cpp
22+
RISCV.cpp
23+
SPIR.cpp
24+
Sparc.cpp
25+
SystemZ.cpp
26+
TCE.cpp
27+
VE.cpp
28+
WebAssembly.cpp
29+
X86.cpp
30+
XCore.cpp
31+
)

0 commit comments

Comments
 (0)