Skip to content
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

Merged
merged 1 commit into from
Sep 23, 2017

Conversation

return
Copy link
Contributor

@return return commented Aug 23, 2017

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.

@slavapestov
Copy link
Contributor

Awesome!

@CodaFi
Copy link
Contributor

CodaFi commented Aug 23, 2017

You'll also want to update this file to get standard library command line support for Haiku.

Copy link
Collaborator

@xwu xwu left a 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.

image_info i_info;
int32 image_cookie = 0;
int ret = 0;
while(get_next_image_info(team_id, &image_cookie, &i_info) == B_OK)
Copy link
Collaborator

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.
Copy link
Collaborator

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.

#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));
Copy link
Collaborator

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.

struct rusage RU;
::getrusage(RUSAGE_CHILDREN, &RU);
return RU.ru_maxrss;
#else
return 0;
Copy link
Collaborator

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.

@@ -353,6 +353,8 @@ function(_add_variant_link_flags)
# options. This causes conflicts.
list(APPEND result "-nostdlib")
endif()
elseif("${LFLAGS_SDK}" STREQUAL "HAIKU")
Copy link
Collaborator

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 elseifs.

@@ -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"
Copy link
Collaborator

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.

@@ -2332,6 +2344,24 @@ for host in "${ALL_HOSTS[@]}"; do
-DLLDB_ALLOW_STATIC_BINDINGS=1
)
;;
haiku-*)
Copy link
Collaborator

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)
Copy link
Collaborator

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")
Copy link
Collaborator

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.

@return
Copy link
Contributor Author

return commented Aug 28, 2017

@xwu @CodaFi I have updated the patches to fit the guidelines, could you please review my changes and check if this is OK to test?

@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@return return changed the title [WIP] [Do Not Merge] Add Initial platform support for Haiku. Add Initial platform support for Haiku. Aug 28, 2017
@@ -33,12 +33,16 @@ using namespace llvm::sys;
static size_t
getChildrenMaxResidentSetSize() {
#if defined(HAVE_GETRUSAGE)
#if !defined(__HAIKU__)
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

@xwu xwu Aug 28, 2017

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.

@return
Copy link
Contributor Author

return commented Aug 28, 2017

@CodaFi @xwu Thank you very much for reviewing my changes, are there anymore changes left to do?

@CodaFi
Copy link
Contributor

CodaFi commented Sep 4, 2017

@swift-ci please smoke test

@return
Copy link
Contributor Author

return commented Sep 4, 2017

@CodaFi I've already sent a patch for this to LLVM, but this patch isn't included in swift-llvm stable yet. Which is why the build is failing.

@korli
Copy link

korli commented Sep 5, 2017

@return I suppose you could cherry-pick apple/swift-llvm@aea1537 in a PR for the stable branch.

@return
Copy link
Contributor Author

return commented Sep 5, 2017

@korli I've sent a PR to swift-llvm.

@korli
Copy link

korli commented Sep 15, 2017

@swift-ci please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Sep 16, 2017

@korli PR testing requires privileges. See swift.org

@swift-ci please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Sep 17, 2017

@swift-ci please smoke test

@korli
Copy link

korli commented Sep 20, 2017

@CodaFi thanks for the tests.
@return it seems a change happened on stdlib/public/SwiftShims/LibcShims.h, could you please rebase?

@return
Copy link
Contributor Author

return commented Sep 21, 2017

@korli I've rebased my patches and fixed the conflict. @CodaFi Could you please smoke test this commit?

@gottesmm
Copy link
Contributor

(Drive by smoke test)

@swift-ci smoke test

@@ -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;
Copy link

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)

Copy link
Contributor Author

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.

@korli
Copy link

korli commented Sep 22, 2017

LGTM

@CodaFi
Copy link
Contributor

CodaFi commented Sep 22, 2017

@swift-ci please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Sep 22, 2017

@return If you have no other qualms, this looks good to merge.

@return
Copy link
Contributor Author

return commented Sep 22, 2017

@CodaFi These patches are also fine with me.

@CodaFi
Copy link
Contributor

CodaFi commented Sep 23, 2017

⛵️

@CodaFi CodaFi merged commit aee81d2 into swiftlang:master Sep 23, 2017
@return return deleted the swift-4-haiku-upstream-1 branch January 1, 2018 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants