-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Initial platform support for Haiku. #11583
Conversation
Awesome! |
You'll also want to update this file to get standard library command line support for Haiku. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hurray! Just some drive-by formatting nits.
stdlib/public/runtime/HaikuPort.cpp
Outdated
image_info i_info; | ||
int32 image_cookie = 0; | ||
int ret = 0; | ||
while(get_next_image_info(team_id, &image_cookie, &i_info) == B_OK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Code style in this particular function seems to be very different from everything else, even in this file. Generally, the project uses two spaces instead of four, a space between while
or if
and the opening paren, and {
on the same line as the condition. Also, what's going on with the indentation of this particular line?
set(GLIBC_ARCH_INCLUDE_PATH "/system/develop/headers/posix") | ||
set(GLIBC_SYSROOT_RELATIVE_INCLUDE_PATH "/system/develop/headers/") | ||
else() | ||
# Determine the location of glibc headers based on the target. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent here and on subsequent lines should be two spaces instead of four.
lib/Driver/ToolChains.cpp
Outdated
#if defined(__HAIKU__) | ||
// For now, passing -use-ld on Haiku doesn't work as swiftc doesn't recognise | ||
// it. Passing -use-ld= as the argument works fine. | ||
Arguments.push_back(context.Args.MakeArgString("-use-ld=" + Linker)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent here is missing a space.
lib/Basic/Statistic.cpp
Outdated
struct rusage RU; | ||
::getrusage(RUSAGE_CHILDREN, &RU); | ||
return RU.ru_maxrss; | ||
#else | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: needs to be indented two spaces.
cmake/modules/AddSwift.cmake
Outdated
@@ -353,6 +353,8 @@ function(_add_variant_link_flags) | |||
# options. This causes conflicts. | |||
list(APPEND result "-nostdlib") | |||
endif() | |||
elseif("${LFLAGS_SDK}" STREQUAL "HAIKU") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent here is inconsistent with other elseif
s.
utils/build-script-impl
Outdated
@@ -425,6 +427,11 @@ function set_build_options_for_host() { | |||
SWIFT_HOST_VARIANT_SDK="CYGWIN" | |||
SWIFT_HOST_VARIANT_ARCH="x86_64" | |||
;; | |||
haiku-x86_64) | |||
SWIFT_HOST_VARIANT="haiku" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indentation is inconsistent on this line.
utils/build-script-impl
Outdated
@@ -2332,6 +2344,24 @@ for host in "${ALL_HOSTS[@]}"; do | |||
-DLLDB_ALLOW_STATIC_BINDINGS=1 | |||
) | |||
;; | |||
haiku-*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indentation is inconsistent as compared to cygwin-*)
above and macosx-*)
below.
@@ -186,6 +186,9 @@ def find_tool(self, *names): | |||
return found | |||
return None | |||
|
|||
class Haiku(GenericUnix): | |||
def __init__(self): | |||
super(Haiku, self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indentation should be four spaces and not three here.
CMakeLists.txt
Outdated
@@ -536,6 +536,8 @@ else() | |||
set(SWIFT_HOST_VARIANT_SDK_default "CYGWIN") | |||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") | |||
set(SWIFT_HOST_VARIANT_SDK_default "WINDOWS") | |||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku") | |||
set(SWIFT_HOST_VARIANT_SDK_default "HAIKU") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indentation here is inconsistent with other lines; use two spaces instead of five.
009e6d2
to
048ebc2
Compare
lib/Driver/ToolChains.cpp
Outdated
@@ -1578,7 +1578,13 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job, | |||
Linker = getDefaultLinker(); | |||
} | |||
if (!Linker.empty()) { | |||
#if defined(__HAIKU__) | |||
// For now, passing -use-ld on Haiku doesn't work as swiftc doesn't recognise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Did you mean -fuse-ld
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodaFi This typo has been refactored.
048ebc2
to
73d2334
Compare
lib/Basic/Statistic.cpp
Outdated
@@ -33,12 +33,16 @@ using namespace llvm::sys; | |||
static size_t | |||
getChildrenMaxResidentSetSize() { | |||
#if defined(HAVE_GETRUSAGE) | |||
#if !defined(__HAIKU__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a separate #if?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xwu Oops, sorry about that. Would changing it to #if defined(HAVE_GETRUSAGE) && !defined(__HAIKU__)
and removing lines 43-45 be preferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xwu I've just refactored this change and it builds fine. Are there any more issues with this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@return I’ve only had a cursory look through the changes, but that’s all I’ve got for now :) Thanks for humoring me.
73d2334
to
070fdd6
Compare
@swift-ci please smoke test |
@return I suppose you could cherry-pick apple/swift-llvm@aea1537 in a PR for the stable branch. |
@korli I've sent a PR to swift-llvm. |
@swift-ci please smoke test |
070fdd6
to
67ace9b
Compare
@swift-ci please smoke test |
67ace9b
to
0223b3f
Compare
(Drive by smoke test) @swift-ci smoke test |
stdlib/public/SwiftShims/LibcShims.h
Outdated
@@ -121,6 +121,8 @@ typedef unsigned int __swift_thread_key_t; | |||
typedef int __swift_thread_key_t; | |||
#elif defined(_WIN32) | |||
typedef unsigned long __swift_thread_key_t; | |||
#elif defined(__HAIKU__) | |||
typedef int __swift_pthread_key_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@return it should be __swift_thread_key_t (without p)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@korli Thanks, this has been fixed now.
0223b3f
to
e7d7ef8
Compare
LGTM |
@swift-ci please smoke test |
@return If you have no other qualms, this looks good to merge. |
@CodaFi These patches are also fine with me. |
⛵️ |
This pull request adds initial platform support for building swiftc and stdlib on 64bit Haiku (x86_64-unknown-haiku) using the build-script as part of my GSoC project with the Haiku project.
It also requires this commit, where the OS check is used here. Other than that, it builds and works fine on Haiku and I'm currently adding more support for the test-suite and the foundation libraries.
Resolves SR-NNNN.