Skip to content

build-script: build static version of Foundation #20824

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

Merged
merged 1 commit into from
Nov 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
SKSTRESSTESTER_SOURCE_DIR="${WORKSPACE}/swift-stress-tester/SourceKitStressTester"
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
FOUNDATION_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
LIBDISPATCH_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
LIBICU_SOURCE_DIR="${WORKSPACE}/icu"
Expand Down Expand Up @@ -1230,6 +1231,9 @@ if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
fi
if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" foundation)
if [[ -z "${SKIP_BUILD_STATIC_FOUNDATION}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" foundation_static)
fi
fi
if [[ ! "${SKIP_BUILD_LLBUILD}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" llbuild)
Expand Down Expand Up @@ -1571,7 +1575,7 @@ function build_directory_bin() {
xctest)
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
;;
foundation)
foundation|foundation_static)
echo "${root}/${FOUNDATION_BUILD_TYPE}/bin"
;;
libdispatch|libdispatch_static)
Expand Down Expand Up @@ -1716,7 +1720,7 @@ function cmake_config_opt() {
xctest)
echo "--config ${XCTEST_BUILD_TYPE}"
;;
foundation)
foundation|foundation_static)
echo "--config ${FOUNDATION_BUILD_TYPE}"
;;
libdispatch|libdispatch_static)
Expand Down Expand Up @@ -2604,7 +2608,7 @@ for host in "${ALL_HOSTS[@]}"; do
esac

;;
foundation)
foundation|foundation_static)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we build a static ICU as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that would be a good idea to do given the rest of the static linking, and the behaviour of glibc's libdl. But, I think that is beyond the scope of this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

A static libICU is already built on linux as part of the --libicu option:

if [ $(true_false "${BUILD_SWIFT_STATIC_STDLIB}") == "TRUE" ]; then
         libicu_enable_static="--enable-static"
else
         libicu_enable_static=""
fi

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, cool. Um, why is that controlled by static stdlib though? Lets get this working and then adjust the static build to use the static ICU.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since ICU is now bundled (presumably so that "🏴󠁧󠁢󠁥󠁮󠁧󠁿".count == 1 instead of possibly 7) it's on us to build the static version of it as well. -static-stdlib changes the library search path to lib/swift_static instead of lib/swift so if there's no icu libs there it won't work.

Copy link
Contributor

Choose a reason for hiding this comment

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

What should it be controlled by? Are we adding an extra --static- flag for each lib? maybe it would be better with a --static-libs flag instead to build them all together, -static-stdlib requires all of them anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

IOW it seems ICU is now considered part of the stdlib, so flags that control the linkage of the stdlib should cover ICU now too

Copy link
Member Author

Choose a reason for hiding this comment

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

@kevints, this is about the build-script, not the the driver flag. The driver flag remains -static-stdlib. The icu libs are already present in the swift_static directory.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok @compnerd I was confused then. This looks good to me

# The configuration script requires knowing about XCTest's
# location for building and running the tests. Note that XCTest
# is not yet built at this point.
Expand All @@ -2625,8 +2629,12 @@ for host in "${ALL_HOSTS[@]}"; do
-DICU_INCLUDE_DIR:PATH=${ICU_ROOT}/include
-DICU_UC_LIBRARIES:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_UC_LIBRARY:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_UC_LIBRARY_DEBUG:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_UC_LIBRARY_RELEASE:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_I18N_LIBRARIES:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
-DICU_I18N_LIBRARY:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
-DICU_I18N_LIBRARY_DEBUG:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
-DICU_I18N_LIBRARY_RELEASE:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
)
else
LIBICU_BUILD_ARGS=()
Expand Down Expand Up @@ -2662,6 +2670,8 @@ for host in "${ALL_HOSTS[@]}"; do
# NOTE(compnerd) we disable tests because XCTest is not ready
# yet, but we will reconfigure when the time comes.
-DENABLE_TESTING:BOOL=NO

-DBUILD_SHARED_LIBS=$([[ ${product} == foundation_static ]] && echo "NO" || echo "YES")
)

;;
Expand Down Expand Up @@ -3225,8 +3235,12 @@ for host in "${ALL_HOSTS[@]}"; do
-DICU_INCLUDE_DIR:PATH=${ICU_ROOT}/include
-DICU_UC_LIBRARIES:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_UC_LIBRARY:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_UC_LIBRARY_DEBUG:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_UC_LIBRARY_RELEASE:FILEPATH=${ICU_LIBDIR}/libicuucswift.so
-DICU_I18N_LIBRARIES:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
-DICU_I18N_LIBRARY:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
-DICU_I18N_LIBRARY_DEBUG:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
-DICU_I18N_LIBRARY_RELEASE:FILEPATH=${ICU_LIBDIR}/libicui18nswift.so
)
else
LIBICU_BUILD_ARGS=()
Expand Down Expand Up @@ -3266,6 +3280,9 @@ for host in "${ALL_HOSTS[@]}"; do
results_targets=( "test" )
executable_target=("TestFoundation")
;;
foundation_static)
continue
;;
libdispatch)
if [[ "${SKIP_TEST_LIBDISPATCH}" ]]; then
continue
Expand Down Expand Up @@ -3518,7 +3535,7 @@ for host in "${ALL_HOSTS[@]}"; do
esac

;;
foundation)
foundation|foundation_static)
# FIXME: Foundation doesn't build from the script on OS X
if [[ ${host} == "macosx"* ]]; then
echo "Skipping Foundation on OS X -- use the Xcode project instead"
Expand Down