Skip to content

Commit eaa1d9a

Browse files
committed
ldc: Add support for GNU/Hurd
1 parent c8305d0 commit eaa1d9a

6 files changed

Lines changed: 22 additions & 6 deletions

File tree

driver/linker-gcc.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ void ArgsBuilder::addLTOLinkFlags() {
200200
global.params.targetTriple->isOSFreeBSD() ||
201201
global.params.targetTriple->isOSNetBSD() ||
202202
global.params.targetTriple->isOSOpenBSD() ||
203-
global.params.targetTriple->isOSDragonFly()) {
203+
global.params.targetTriple->isOSDragonFly() ||
204+
global.params.targetTriple->isOSHurd()) {
204205
// LLD supports LLVM LTO natively, do not add the plugin itself.
205206
// Otherwise, assume that ld.gold or ld.bfd is used with plugin support.
206207
addLTOGoldPluginFlags(!isLld);
@@ -435,6 +436,7 @@ void ArgsBuilder::addCppStdlibLinkFlags(const llvm::Triple &triple) {
435436
case llvm::Triple::NetBSD:
436437
case llvm::Triple::OpenBSD:
437438
case llvm::Triple::DragonFly:
439+
case llvm::Triple::Hurd:
438440
args.push_back("-lstdc++");
439441
break;
440442
case llvm::Triple::Darwin:
@@ -689,6 +691,7 @@ void ArgsBuilder::addDefaultPlatformLibs() {
689691
case llvm::Triple::NetBSD:
690692
case llvm::Triple::OpenBSD:
691693
case llvm::Triple::DragonFly:
694+
case llvm::Triple::Hurd:
692695
addSoname = true;
693696
args.push_back("-lpthread");
694697
args.push_back("-lm");

driver/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,13 @@ void registerPredefinedTargetVersions() {
918918
VersionCondition::addPredefinedGlobalIdent("CppRuntime_LLVM");
919919
VersionCondition::addPredefinedGlobalIdent("CppRuntime_Clang"); // legacy
920920
break;
921+
case llvm::Triple::Hurd:
922+
VersionCondition::addPredefinedGlobalIdent("Hurd");
923+
VersionCondition::addPredefinedGlobalIdent("Posix");
924+
VersionCondition::addPredefinedGlobalIdent("CRuntime_Glibc");
925+
VersionCondition::addPredefinedGlobalIdent("CppRuntime_GNU");
926+
VersionCondition::addPredefinedGlobalIdent("CppRuntime_Gcc"); // legacy
927+
break;
921928
default:
922929
if (triple.getEnvironment() == llvm::Triple::Android) {
923930
VersionCondition::addPredefinedGlobalIdent("Android");

gen/modules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ RegistryStyle getModuleRegistryStyle() {
104104
if (t.isOSWindows() || t.getEnvironment() == llvm::Triple::Android ||
105105
t.isOSBinFormatWasm() || t.isOSDarwin() || t.isOSLinux() ||
106106
t.isOSFreeBSD() || t.isOSNetBSD() || t.isOSOpenBSD() ||
107-
t.isOSDragonFly()) {
107+
t.isOSDragonFly() || t.isOSHurd()) {
108108
return RegistryStyle::section;
109109
}
110110

gen/target.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ void Target::_init(const Param &params) {
149149
os = OS_DragonFlyBSD;
150150
} else if (triple.isOSSolaris()) {
151151
os = OS_Solaris;
152+
else if (triple.isOSHurd()) {
153+
os = OS_Hurd;
152154
} else {
153155
os = OS_Freestanding;
154156
}

runtime/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ else()
9494
endif()
9595

9696
set(SHARED_LIBS_SUPPORTED OFF)
97-
if("${TARGET_SYSTEM}" MATCHES "Windows|Linux|FreeBSD|DragonFly|APPLE")
97+
if("${TARGET_SYSTEM}" MATCHES "Windows|Linux|FreeBSD|DragonFly|APPLE|GNU")
9898
set(SHARED_LIBS_SUPPORTED ON)
9999
endif()
100100

@@ -175,6 +175,7 @@ file(GLOB_RECURSE DRUNTIME_D_BIONIC ${RUNTIME_DIR}/src/core/sys/bionic/*.d)
175175
file(GLOB_RECURSE DRUNTIME_D_DARWIN ${RUNTIME_DIR}/src/core/sys/darwin/*.d)
176176
file(GLOB_RECURSE DRUNTIME_D_DRAGONFLYBSD ${RUNTIME_DIR}/src/core/sys/dragonflybsd/*.d)
177177
file(GLOB_RECURSE DRUNTIME_D_FREEBSD ${RUNTIME_DIR}/src/core/sys/freebsd/*.d)
178+
file(GLOB_RECURSE DRUNTIME_D_HURD ${RUNTIME_DIR}/src/core/sys/hurd/*.d)
178179
file(GLOB_RECURSE DRUNTIME_D_LINUX ${RUNTIME_DIR}/src/core/sys/linux/*.d)
179180
file(GLOB_RECURSE DRUNTIME_D_NETBSD ${RUNTIME_DIR}/src/core/sys/netbsd/*.d)
180181
file(GLOB_RECURSE DRUNTIME_D_OPENBSD ${RUNTIME_DIR}/src/core/sys/openbsd/*.d)
@@ -183,9 +184,9 @@ file(GLOB_RECURSE DRUNTIME_D_SOLARIS ${RUNTIME_DIR}/src/core/sys/solaris/*.d)
183184
file(GLOB_RECURSE DRUNTIME_D_WINDOWS ${RUNTIME_DIR}/src/core/sys/windows/*.d)
184185
list(REMOVE_ITEM DRUNTIME_D
185186
${DRUNTIME_D_BIONIC} ${DRUNTIME_D_DARWIN} ${DRUNTIME_D_DRAGONFLYBSD}
186-
${DRUNTIME_D_FREEBSD} ${DRUNTIME_D_LINUX} ${DRUNTIME_D_NETBSD}
187-
${DRUNTIME_D_OPENBSD} ${DRUNTIME_D_POSIX} ${DRUNTIME_D_SOLARIS}
188-
${DRUNTIME_D_WINDOWS}
187+
${DRUNTIME_D_FREEBSD} ${DRUNTIME_D_HURD} ${DRUNTIME_D_LINUX}
188+
${DRUNTIME_D_NETBSD} ${DRUNTIME_D_OPENBSD} ${DRUNTIME_D_POSIX}
189+
${DRUNTIME_D_SOLARIS} ${DRUNTIME_D_WINDOWS}
189190
)
190191
if("${TARGET_SYSTEM}" MATCHES "Windows")
191192
list(APPEND DRUNTIME_D ${DRUNTIME_D_WINDOWS})
@@ -206,6 +207,8 @@ elseif("${TARGET_SYSTEM}" MATCHES "UNIX")
206207
list(APPEND DRUNTIME_D ${DRUNTIME_D_OPENBSD})
207208
elseif("${TARGET_SYSTEM}" MATCHES "SunOS")
208209
list(APPEND DRUNTIME_D ${DRUNTIME_D_SOLARIS})
210+
elseif("${TARGET_SYSTEM}" MATCHES "GNU")
211+
list(APPEND DRUNTIME_D ${DRUNTIME_D_HURD})
209212
endif()
210213
endif()
211214

runtime/druntime/src/rt/sections_ldc.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ else version (FreeBSD) {}
3131
else version (DragonFlyBSD) {}
3232
else version (NetBSD) {}
3333
else version (OpenBSD) {}
34+
else version (Hurd) {}
3435
else version (Windows) {}
3536
else version (LDC):
3637

0 commit comments

Comments
 (0)