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

Partial FreeBSD Support #203

Merged
merged 18 commits into from Dec 5, 2015
Merged

Conversation

landonf
Copy link
Contributor

@landonf landonf commented Dec 4, 2015

This provides a non-controversial baseline for FreeBSD support.

Additional work will be required for the full port, but with this initial work -- plus local work-arounds for linker script behavior and use of pkg-installed libc++ -- I'm able to successfully compete a full Swift build on FreeBSD 10.x.

@jckarter
Copy link
Member

jckarter commented Dec 4, 2015

Nice! @gribozavr is probably the best person to review the build system changes.

@gribozavr
Copy link
Collaborator

@landonf Great work! Please update the pull request per comments above. Which systems have you tested this branch on?

@landonf
Copy link
Contributor Author

landonf commented Dec 4, 2015

Thanks for the feedback; I believe I've integrated all the requested changes. I also moved ahead with a common Unix toolchain class pending additional comments on a preferred alternative.

I've only tested locally against x86-64-freebsd10.2 (-STABLE)

@gribozavr
Copy link
Collaborator

I'll run the tests on OS X and Linux, while waiting for feedback from @jrose-apple .

@gribozavr
Copy link
Collaborator

@landonf The OS X build passed all tests.

The new test fails on Linux.

FAIL: Swift :: BuildConfigurations/x64FreeBSDTarget.swift (141 of 7260)
******************** TEST 'Swift :: BuildConfigurations/x64FreeBSDTarget.swift' FAILED ********************
Script:
--
'/home/gribozavr/src.public/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift' -frontend -module-cache-path '/tmp/swift-testsuite-clang-module-cacheQ2TPZE' -disable-objc-attr-requires-foundation-module -parse /home/gribozavr/src.public/swift/test/BuildConfigurations/x64FreeBSDTarget.swift -verify -D FOO -D BAR -target x86_64-freebsd10 -disable-objc-interop -D FOO -parse-stdlib
'/home/gribozavr/src.public/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-ide-test' -module-cache-path '/tmp/swift-testsuite-clang-module-cacheQ2TPZE' -completion-cache-path '/tmp/swift-testsuite-completion-cachee5rxPO' -test-input-complete -source-filename=/home/gribozavr/src.public/swift/test/BuildConfigurations/x64FreeBSDTarget.swift -target x86_64-freebsd10
--
Exit Code: 1

Command Output (stderr):
--
<unknown>:0: error: unsupported target OS: ''

--

********************

I think this is because the FreeBSD toolchain is being disabled on Linux with a #if in the C++ source. Could you take a look?

@landonf
Copy link
Contributor Author

landonf commented Dec 4, 2015

@gribozavr My fault for dropping SWIFT_ENABLE_TARGET_FREEBSD without verifying that it didn't break lib/Driver/CMakeLists.txt target define handling.

How did you want to handle this for Linux? Should we just enable both targets by default? Or should I bring back SWIFT_ENABLE_TARGET_FREEBSD and make the tests conditional on the targets being enabled?

@gribozavr
Copy link
Collaborator

@landonf I'd prefer that we drop the Linux option, too.

@gribozavr
Copy link
Collaborator

@landonf In fact, I'll do it now, give me an hour.

@jrose-apple
Copy link
Contributor

In the spirit of incremental development, can we do these as separate pull requests? Drop SWIFT_ENABLE_TARGET_LINUX, rename toolchain and fix-up the Driver library in preparation for the main change, then actually add the support. Or whatever units make sense to you. (Feel free to rewrite history ahead of the merges.)

Aside: Sorry for the trouble, Landon. I'm/We're very happy to have you working on this even as I'm pushing for this extra process. Having small, logically distinct commits is especially important if we ever need to bisect a failure—it's better to be able to isolate a specific change rather than potentially having to revert the whole merge commit. Also, once a change is in master, others are held accountable for not breaking it. :-)

@gribozavr
Copy link
Collaborator

I'm dropping SWIFT_ENABLE_TARGET_LINUX in a separate change.

@gribozavr
Copy link
Collaborator

Removed SWIFT_ENABLE_TARGET_LINUX in a3c92e1. Unfortunately this created merge conflicts. Sorry for the churn @landonf .

@landonf
Copy link
Contributor Author

landonf commented Dec 5, 2015

@gribozavr Thanks! No problem; I've merged in the changes (and adopted @jrose-apple's suggested "GenericUnix").

@gribozavr
Copy link
Collaborator

Running tests again.

@gribozavr
Copy link
Collaborator

@landonf The -target option accepts a triple. Please apply a patch like this to your branch (use a more correct triple if required):

diff --git a/test/BuildConfigurations/x64FreeBSDTarget.swift b/test/BuildConfigurations/x64FreeBSDTarget.swift
index 619d4f5..284060f 100644
--- a/test/BuildConfigurations/x64FreeBSDTarget.swift
+++ b/test/BuildConfigurations/x64FreeBSDTarget.swift
@@ -1,5 +1,5 @@
-// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-freebsd10 -disable-objc-interop -D FOO -parse-stdlib
-// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-freebsd10
+// RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-freebsd10 -disable-objc-interop -D FOO -parse-stdlib
+// RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-freebsd10

 #if arch(x86_64) && os(FreeBSD) && _runtime(_Native)
 class C {}

With this patch, tests pass on Linux and OS X.

@landonf
Copy link
Contributor Author

landonf commented Dec 5, 2015

Thanks, will do; I'm going to bring up a Linux machine so I can properly test locally.

This reverts:
- Adopt proper freebsd triple as required by Swift's build system.
- Revert "Add FreeBSD target_* support.

These will be re-introduced in a later patch that brings up the FreeBSD
test suite.
@landonf
Copy link
Contributor Author

landonf commented Dec 5, 2015

@gribozavr Great; patchset now matches your change.

TC = new toolchains::Linux(*this, Target);
TC = new toolchains::GenericUnix(*this, Target);
break;
case llvm::Triple::FreeBSD:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just let this fall through instead of duplicating code?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed via 109d8e6, thanks!

gribozavr added a commit that referenced this pull request Dec 5, 2015
@gribozavr gribozavr merged commit 16de5d1 into apple:master Dec 5, 2015
@krzyzanowskim
Copy link
Contributor

Does this change means that most #if os(Linux) should be now #if os(Linux) || os(FreeBSD) and all else conditions are undefined now?

#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
import Darwin
#elseif os(Linux)
import Glibc
#endif

ref:

#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)

@gribozavr
Copy link
Collaborator

Yes, all these places need to be audited (we tried to write them in such a way that a new platform would cause build breakage rather than silently choosing some behavior), but not all of them would become os(Linux) || os(FreeBSD). For example, FreeBSD does not use Glibc, it uses BSD libc, so the module likely wouldn't be called Glibc.

modocache added a commit to modocache/swift that referenced this pull request Jan 7, 2016
Many of the conflicts stemmed from FreeBSD support, added in
apple#203.

Conflicts:
- CMakeLists.txt
- cmake/modules/AddSwift.cmake
- lib/Basic/LangOptions.cpp
- lib/Driver/ToolChains.cpp
- stdlib/public/Glibc/CMakeLists.txt
- stdlib/public/core/CMakeLists.txt
- stdlib/public/runtime/CMakeLists.txt
- stdlib/public/runtime/Casting.cpp
- stdlib/public/stubs/CMakeLists.txt
- stdlib/public/stubs/LibcShims.cpp
- stdlib/public/stubs/Stubs.cpp
- test/CMakeLists.txt
- utils/build-script-impl
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
update libpwq and libkqueue submodule versions
slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
update libpwq and libkqueue submodule versions

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
dabelknap added a commit to dabelknap/swift that referenced this pull request Jan 18, 2019
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
Update hash for IBAnimatableApp to build with Swift 4
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.

None yet

6 participants