Skip to content

Commit 8ffeeb9

Browse files
committed
simplify after 6f6dc1f
Created using spr 1.3.5-bogner
2 parents 31951fe + 6f6dc1f commit 8ffeeb9

File tree

14 files changed

+69
-44
lines changed

14 files changed

+69
-44
lines changed

bolt/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ if(BOLT_BUILT_STANDALONE)
4646
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
4747
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
4848

49+
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
50+
add_definitions(${LLVM_DEFINITIONS_LIST})
51+
list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
52+
4953
include(AddLLVM)
5054
include(TableGen)
5155
include_directories(${LLVM_INCLUDE_DIRS})

clang/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ if(CLANG_BUILT_STANDALONE)
6868
option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
6969
option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
7070

71+
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
72+
add_definitions(${LLVM_DEFINITIONS_LIST})
73+
list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
74+
7175
include(AddLLVM)
7276
include(TableGen)
7377
include(HandleLLVMOptions)

flang/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ if (FLANG_STANDALONE_BUILD)
140140
if (NOT DEFINED LLVM_MAIN_SRC_DIR)
141141
set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
142142
endif()
143+
144+
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
145+
add_definitions(${LLVM_DEFINITIONS_LIST})
146+
list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
147+
143148
include(AddLLVM)
144149
include(HandleLLVMOptions)
145150
include(VersionFromVCS)

lld/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ if(LLD_BUILT_STANDALONE)
3939
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
4040
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
4141

42+
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
43+
add_definitions(${LLVM_DEFINITIONS_LIST})
44+
list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
45+
4246
include(AddLLVM)
4347
include(TableGen)
4448
include(HandleLLVMOptions)

lldb/cmake/modules/LLDBStandalone.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ endif()
8585
# CMake modules to be in that directory as well.
8686
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
8787

88+
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
89+
add_definitions(${LLVM_DEFINITIONS_LIST})
90+
list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
91+
8892
include(AddLLVM)
8993
include(TableGen)
9094
include(HandleLLVMOptions)

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ class MCAsmBackend {
8888
/// Get information on a fixup kind.
8989
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const;
9090

91-
// Hook to check if a relocation is needed. The default implementation tests
92-
// whether the MCValue has a relocation specifier.
91+
// Hook used by the default `addReloc` to check if a relocation is needed.
9392
virtual bool shouldForceRelocation(const MCAssembler &, const MCFixup &,
94-
const MCValue &, const MCSubtargetInfo *);
93+
const MCValue &, const MCSubtargetInfo *) {
94+
return false;
95+
}
9596

9697
/// Hook to check if extra nop bytes must be inserted for alignment directive.
9798
/// For some targets this may be necessary in order to support linker

llvm/lib/MC/MCAsmBackend.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ MCFixupKindInfo MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
109109
return Builtins[Kind - FK_NONE];
110110
}
111111

112-
bool MCAsmBackend::shouldForceRelocation(const MCAssembler &, const MCFixup &,
113-
const MCValue &Target,
114-
const MCSubtargetInfo *) {
115-
return Target.getSpecifier();
116-
}
117-
118112
bool MCAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &,
119113
const MCFixup &Fixup,
120114
const MCValue &, uint64_t Value,

llvm/lib/Support/raw_socket_stream.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ static Expected<int> getSocketFD(StringRef SocketPath) {
8181
"Create socket failed");
8282
}
8383

84+
#ifdef __CYGWIN__
85+
// On Cygwin, UNIX sockets involve a handshake between connect and accept
86+
// to enable SO_PEERCRED/getpeereid handling. This necessitates accept being
87+
// called before connect can return, but at least the tests in
88+
// llvm/unittests/Support/raw_socket_stream_test do both on the same thread
89+
// (first connect and then accept), resulting in a deadlock. This call turns
90+
// off the handshake (and SO_PEERCRED/getpeereid support).
91+
setsockopt(Socket, SOL_SOCKET, SO_PEERCRED, NULL, 0);
92+
#endif
8493
struct sockaddr_un Addr = setSocketAddr(SocketPath);
8594
if (::connect(Socket, (struct sockaddr *)&Addr, sizeof(Addr)) == -1)
8695
return llvm::make_error<StringError>(getLastSocketErrorCode(),
@@ -147,6 +156,15 @@ Expected<ListeningSocket> ListeningSocket::createUnix(StringRef SocketPath,
147156
return llvm::make_error<StringError>(getLastSocketErrorCode(),
148157
"socket create failed");
149158

159+
#ifdef __CYGWIN__
160+
// On Cygwin, UNIX sockets involve a handshake between connect and accept
161+
// to enable SO_PEERCRED/getpeereid handling. This necessitates accept being
162+
// called before connect can return, but at least the tests in
163+
// llvm/unittests/Support/raw_socket_stream_test do both on the same thread
164+
// (first connect and then accept), resulting in a deadlock. This call turns
165+
// off the handshake (and SO_PEERCRED/getpeereid support).
166+
setsockopt(Socket, SOL_SOCKET, SO_PEERCRED, NULL, 0);
167+
#endif
150168
struct sockaddr_un Addr = setSocketAddr(SocketPath);
151169
if (::bind(Socket, (struct sockaddr *)&Addr, sizeof(Addr)) == -1) {
152170
// Grab error code from call to ::bind before calling ::close

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,28 +104,6 @@ MCFixupKindInfo RISCVAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
104104
return Infos[Kind - FirstTargetFixupKind];
105105
}
106106

107-
// If linker relaxation is enabled, emit relocation to mark the instruction as
108-
// shrinkable by the linker.
109-
bool RISCVAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
110-
const MCFixup &Fixup,
111-
const MCValue &Target,
112-
const MCSubtargetInfo *STI) {
113-
switch (Fixup.getTargetKind()) {
114-
default:
115-
break;
116-
case FK_Data_1:
117-
case FK_Data_2:
118-
case FK_Data_4:
119-
case FK_Data_8:
120-
case FK_Data_leb128:
121-
if (Target.isAbsolute())
122-
return false;
123-
break;
124-
}
125-
126-
return Fixup.needsRelax();
127-
}
128-
129107
bool RISCVAsmBackend::fixupNeedsRelaxationAdvanced(const MCAssembler &,
130108
const MCFixup &Fixup,
131109
const MCValue &,
@@ -674,14 +652,17 @@ bool RISCVAsmBackend::addReloc(MCAssembler &Asm, const MCFragment &F,
674652
return false;
675653
}
676654

655+
// If linker relaxation is enabled and supported by the current relocation,
656+
// generate a relocation and then append a RELAX.
657+
if (Fixup.needsRelax())
658+
IsResolved = false;
677659
if (IsResolved &&
678660
(getFixupKindInfo(Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsPCRel))
679661
IsResolved = isPCRelFixupResolved(Asm, Target.getAddSym(), F);
680662
IsResolved = MCAsmBackend::addReloc(Asm, F, Fixup, Target, FixedValue,
681663
IsResolved, STI);
682-
// If linker relaxation is enabled and supported by the current relocation,
683-
// append a RELAX relocation.
684-
if (!IsResolved && Fixup.needsRelax()) {
664+
665+
if (Fixup.needsRelax()) {
685666
auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_RISCV_RELAX);
686667
Asm.getWriter().recordRelocation(Asm, &F, FA, MCValue::get(nullptr),
687668
FixedValueA);

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ class RISCVAsmBackend : public MCAsmBackend {
6262
std::unique_ptr<MCObjectTargetWriter>
6363
createObjectTargetWriter() const override;
6464

65-
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
66-
const MCValue &Target,
67-
const MCSubtargetInfo *STI) override;
68-
6965
bool fixupNeedsRelaxationAdvanced(const MCAssembler &,
7066
const MCFixup &, const MCValue &, uint64_t,
7167
bool) const override;

0 commit comments

Comments
 (0)