From 7cf93ae61f1e34a9fded4b7365f3f369fe7a4aa6 Mon Sep 17 00:00:00 2001 From: Simon Evans Date: Tue, 11 Oct 2016 22:27:42 +0100 Subject: [PATCH] SR-2280: swiftc -static-stdlib option fails on Linux - Link in static version of libicu if available in preference to the dynamic library when using the -static-stdlib option. --- lib/Driver/CMakeLists.txt | 5 +++ utils/gen-static-stdlib-link-args | 63 ++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt index e0c8898987bde..a9cd1364119a2 100644 --- a/lib/Driver/CMakeLists.txt +++ b/lib/Driver/CMakeLists.txt @@ -30,6 +30,9 @@ if(SWIFT_BUILD_STATIC_STDLIB) set(ICU_STATICLIB "TRUE") else() set(ICU_STATICLIB "FALSE") + find_package(ICU REQUIRED COMPONENTS uc i18n) + get_filename_component(ICU_UC_LIBDIR "${ICU_UC_LIBRARY}" DIRECTORY) + get_filename_component(ICU_I18N_LIBDIR "${ICU_I18N_LIBRARY}" DIRECTORY) endif() set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk") add_custom_command_target(swift_static_stdlib_${sdk}_args @@ -38,6 +41,8 @@ if(SWIFT_BUILD_STATIC_STDLIB) "${sdk}" "${SWIFTSTATICLIB_DIR}/${linkfile}" "${ICU_STATICLIB}" + "${ICU_UC_LIBDIR}" + "${ICU_I18N_LIBDIR}" OUTPUT "${SWIFTSTATICLIB_DIR}/${linkfile}") diff --git a/utils/gen-static-stdlib-link-args b/utils/gen-static-stdlib-link-args index af717ea470019..39e518d22b655 100755 --- a/utils/gen-static-stdlib-link-args +++ b/utils/gen-static-stdlib-link-args @@ -2,34 +2,62 @@ # # Generate the static-stdlib-args.lnk used by the -static-stdlib option for -# 'GenericUnix' (eg linux) plaforms. If libicu is built locally then include -# libicudata +# 'GenericUnix' (eg linux) plaforms. Tries to find static .a files for libs +# not normally installed by default (currently libicu) +# If libicu is built locally then include libicudata # # SDK=$1 OUTPUTFILE=$2 ICU_STATIC_LIB=$3 +# libdirs from pkg-config +ICU_UC_LIBDIR=$4 +ICU_I18N_LIBDIR=$5 -if [ "${ICU_STATIC_LIB}" == "TRUE" ]; then - read -r -d '' ICU_LIBS <$OUTPUTFILE <