Discard swift.ld and support gold linker

This commit is contained in:
William Dillon
2016-01-20 02:50:33 +00:00
parent f889bcc64f
commit d0d9b1de5a
13 changed files with 276 additions and 115 deletions

View File

@@ -221,7 +221,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if(SWIFT_BUILT_STANDALONE)
project(Swift)
project(Swift C CXX ASM)
endif()
if("${CMAKE_SYSTEM_NAME}" STREQUAL "")

View File

@@ -173,15 +173,9 @@ function(_add_variant_link_flags
result)
if("${sdk}" STREQUAL "LINUX")
if("${arch}" STREQUAL "armv7")
list(APPEND result "-lpthread" "-ldl" "-Wl,-Bsymbolic")
elseif("${arch}" STREQUAL "armv6")
list(APPEND result "-lpthread" "-ldl" "-Wl,-Bsymbolic")
else()
list(APPEND result "-lpthread" "-ldl")
endif()
elseif("${sdk}" STREQUAL "FREEBSD")
list(APPEND result "-lpthread" "-Wl,-Bsymbolic")
list(APPEND result "-lpthread")
else()
list(APPEND result "-lobjc")
endif()
@@ -856,6 +850,22 @@ function(_add_swift_library_single target name)
set(SWIFTLIB_SINGLE_API_NOTES "${module_name}")
endif()
# On platforms that use ELF binaries (for now that is Linux and FreeBSD)
# we add markers for metadata sections in the shared libraries using
# these object files. This wouldn't be necessary if the link was done by
# the swift binary: rdar://problem/19007002
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR
"${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
if("${libkind}" STREQUAL "SHARED")
set(arch_subdir "${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}")
set(SWIFT_SECTIONS_OBJECT_BEGIN "${arch_subdir}/swift_begin.o")
set(SWIFT_SECTIONS_OBJECT_END "${arch_subdir}/swift_end.o")
endif()
endif()
# FIXME: don't actually depend on the libraries in SWIFTLIB_SINGLE_LINK_LIBRARIES,
# just any swiftmodule files that are associated with them.
handle_swift_sources(
@@ -877,8 +887,21 @@ function(_add_swift_library_single target name)
INSTALL_IN_COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}")
add_library("${target}" ${libkind}
${SWIFT_SECTIONS_OBJECT_BEGIN}
${SWIFTLIB_SINGLE_SOURCES}
${SWIFTLIB_SINGLE_EXTERNAL_SOURCES})
${SWIFTLIB_SINGLE_EXTERNAL_SOURCES}
${SWIFT_SECTIONS_OBJECT_END})
# The section metadata objects are generated sources, and we need to tell CMake
# not to expect to find them prior to their generation.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR
"${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
if("${libkind}" STREQUAL "SHARED")
set_source_files_properties(${SWIFT_SECTIONS_OBJECT_BEGIN} PROPERTIES GENERATED 1)
set_source_files_properties(${SWIFT_SECTIONS_OBJECT_END} PROPERTIES GENERATED 1)
add_dependencies("${target}" section_magic)
endif()
endif()
if (dtrace_dependency_targets)
add_dependencies("${target}" ${dtrace_dependency_targets})
@@ -1089,17 +1112,9 @@ function(_add_swift_library_single target name)
"${analyze_code_coverage}"
link_flags)
# Handle gold linker flags for shared libraries.
if(SWIFT_ENABLE_GOLD_LINKER AND SWIFTLIB_SINGLE_SHARED)
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "LINUX")
# Extend the link_flags for the gold linker so long as this
# isn't the standard library. The standard library uses a
# linker script that isn't supported by the gold linker.
if(NOT SWIFTLIB_SINGLE_IS_STDLIB)
if(SWIFT_ENABLE_GOLD_LINKER)
list(APPEND link_flags "-fuse-ld=gold")
endif()
endif()
endif()
# Configure plist creation for OS X.
set(PLIST_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
@@ -1133,16 +1148,6 @@ function(_add_swift_library_single target name)
set(PLIST_INFO_BUILD_VERSION)
endif()
# On Linux and FreeBSD add the linker script that coalesces protocol
# conformance sections. This wouldn't be necessary if the link was done by
# the swift binary: rdar://problem/19007002
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR
"${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
list(APPEND link_flags
"-Xlinker" "-T"
"-Xlinker" "${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}/swift.ld")
endif()
# Convert variables to space-separated strings.
_list_escape_for_shell("${c_compile_flags}" c_compile_flags)
_list_escape_for_shell("${link_flags}" link_flags)

View File

@@ -2009,24 +2009,7 @@ void Driver::printHelp(bool ShowHidden) const {
}
static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple) {
llvm::Triple triple = llvm::Triple(DefaultTargetTriple);
// armv6l and armv7l (which come from linux) are mapped to armv6 and
// armv7 (respectively) within llvm. When a Triple is created by llvm,
// the string is preserved, which keeps the 'l'. This extra character
// causes problems later down the line.
// By explicitly setting the architecture to the subtype that it aliases to,
// we remove that extra character while not introducing other side effects.
if (triple.getOS() == llvm::Triple::Linux) {
if (triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v7) {
triple.setArchName("armv7");
}
if (triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6) {
triple.setArchName("armv6");
}
}
return triple;
return llvm::Triple(DefaultTargetTriple);
}
const ToolChain *Driver::getToolChain(const ArgList &Args) const {

View File

@@ -1091,6 +1091,28 @@ toolchains::GenericUnix::constructInvocation(const AutolinkExtractJobAction &job
return {"swift-autolink-extract", Arguments};
}
// This function maps triples to the architecture component of the path
// where the swift_begin.o and swift_end.o objects can be found. This
// is a stop-gap until full Triple support (ala Clang) exists within swiftc.
StringRef
getSectionMagicArch(const llvm::Triple &Triple) {
if (Triple.isOSLinux()) {
switch(Triple.getSubArch()) {
default:
return Triple.getArchName();
break;
case llvm::Triple::SubArchType::ARMSubArch_v7:
return "armv7";
break;
case llvm::Triple::SubArchType::ARMSubArch_v6:
return "armv6";
break;
}
} else {
return Triple.getArchName();
}
}
ToolChain::InvocationInfo
toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
const JobContext &context) const {
@@ -1109,32 +1131,28 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
break;
case LinkKind::DynamicLibrary:
Arguments.push_back("-shared");
if (getTriple().getOS() == llvm::Triple::Linux) {
if (getTriple().getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v7 ||
getTriple().getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6) {
Arguments.push_back("-Wl,-Bsymbolic");
}
}
break;
}
addPrimaryInputsOfType(Arguments, context.Inputs, types::TY_Object);
addInputsOfType(Arguments, context.InputActions, types::TY_Object);
context.Args.AddAllArgs(Arguments, options::OPT_Xlinker);
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);
context.Args.AddAllArgs(Arguments, options::OPT_F);
if (!context.OI.SDKPath.empty()) {
Arguments.push_back("--sysroot");
Arguments.push_back(context.Args.MakeArgString(context.OI.SDKPath));
}
// Select the linker to use
llvm::SmallString<128> Linker;
StringRef Linker;
if (const Arg *A = context.Args.getLastArg(options::OPT_use_ld)) {
Linker = A->getValue();
} else {
switch(getTriple().getArch()) {
default:
break;
case llvm::Triple::arm:
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb:
// BFD linker has issues wrt relocation of the protocol conformance
// section on these targets, it also generates COPY relocations for
// final executables, as such, unless specified, we default to gold
// linker.
Linker = "gold";
}
}
if (!Linker.empty()) {
@@ -1158,9 +1176,27 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
}
llvm::sys::path::append(RuntimeLibPath,
getPlatformNameForTriple(getTriple()));
// On Linux and FreeBSD (really, ELF binaries) we need to add objects
// to provide markers and size for the metadata sections.
Arguments.push_back(context.Args.MakeArgString(
Twine(RuntimeLibPath) + "/" + getSectionMagicArch(getTriple()) + "/swift_begin.o"));
addPrimaryInputsOfType(Arguments, context.Inputs, types::TY_Object);
addInputsOfType(Arguments, context.InputActions, types::TY_Object);
context.Args.AddAllArgs(Arguments, options::OPT_Xlinker);
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);
context.Args.AddAllArgs(Arguments, options::OPT_F);
if (!context.OI.SDKPath.empty()) {
Arguments.push_back("--sysroot");
Arguments.push_back(context.Args.MakeArgString(context.OI.SDKPath));
}
Arguments.push_back("-L");
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
// Explicitly pass the target to the linker
Arguments.push_back(context.Args.MakeArgString("--target=" + getTriple().str()));
if (context.Args.hasArg(options::OPT_profile_generate)) {
@@ -1193,13 +1229,10 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
Twine("@") + OutputInfo.getPrimaryOutputFilename()));
}
// Add the linker script that coalesces protocol conformance sections.
Arguments.push_back("-Xlinker");
Arguments.push_back("-T");
// FIXME: This should also query the abi type (i.e. gnueabihf)
// It is important that swift_end.o be the last object on the link line
// therefore, it is included just before the output filename.
Arguments.push_back(context.Args.MakeArgString(
Twine(RuntimeLibPath) + "/" + getTriple().getArchName() + "/swift.ld"));
Twine(RuntimeLibPath) + "/" + getSectionMagicArch(getTriple()) + "/swift_end.o"));
// This should be the last option, for convenience in checking output.
Arguments.push_back("-o");

View File

@@ -47,7 +47,27 @@ static void updateRuntimeLibraryPath(SearchPathOptions &SearchPathOpts,
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
// The linux provided triple for ARM contains a trailing 'l'
// denoting little-endian. This is not used in the path for
// libraries. LLVM matches these SubArchTypes to the generic
// ARMSubArch_v7 (for example) type. If that is the case,
// use the base of the architecture type in the library path.
if (Triple.isOSLinux()) {
switch(Triple.getSubArch()) {
default:
llvm::sys::path::append(LibPath, Triple.getArchName());
break;
case llvm::Triple::SubArchType::ARMSubArch_v7:
llvm::sys::path::append(LibPath, "armv7");
break;
case llvm::Triple::SubArchType::ARMSubArch_v6:
llvm::sys::path::append(LibPath, "armv6");
break;
}
} else {
llvm::sys::path::append(LibPath, Triple.getArchName());
}
SearchPathOpts.RuntimeLibraryImportPath = LibPath.str();
}

View File

@@ -180,6 +180,7 @@ add_swift_library(swiftCore SHARED IS_STDLIB IS_STDLIB_CORE
# and the generated directory as dependencies.
FILE_DEPENDS
copy_shim_headers "${SWIFTLIB_DIR}/shims"
section_magic
LINK_FLAGS ${swift_core_link_flags}
PRIVATE_LINK_LIBRARIES ${swift_core_private_link_libraries}
FRAMEWORK_DEPENDS ${swift_core_framework_depends}

View File

@@ -19,7 +19,8 @@ endif()
# Acknowledge that the following sources are known.
set(LLVM_OPTIONAL_SOURCES
Remangle.cpp)
Remangle.cpp
swift_sections.S)
set(swift_runtime_objc_sources)
set(swift_runtime_unicode_normalization_sources)
@@ -52,20 +53,40 @@ add_swift_library(swiftRuntime IS_STDLIB IS_STDLIB_CORE
C_COMPILE_FLAGS ${swift_runtime_compile_flags}
INSTALL_IN_COMPONENT stdlib)
set(object_target_list)
foreach(sdk ${SWIFT_CONFIGURED_SDKS})
if("${sdk}" STREQUAL "LINUX" OR "${sdk}" STREQUAL "FREEBSD")
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
# FIXME: We will need a different linker script for 32-bit builds.
configure_file(
"swift.ld" "${SWIFTLIB_DIR}/${arch_subdir}/swift.ld" COPYONLY)
set(section_magic_begin_name "section_magic_begin_${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}")
set(section_magic_end_name "section_magic_end_${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}")
add_library(${section_magic_begin_name} STATIC swift_sections.S)
set_target_properties(${section_magic_begin_name} PROPERTIES COMPILE_FLAGS "-DSWIFT_BEGIN")
add_library(${section_magic_end_name} STATIC swift_sections.S)
set_target_properties(${section_magic_end_name} PROPERTIES COMPILE_FLAGS "-DSWIFT_END")
add_custom_command_target(${section_magic_begin_name}_begin
OUTPUT "${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${section_magic_begin_name}.dir/swift_sections.S${CMAKE_C_OUTPUT_EXTENSION}" "${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o"
DEPENDS ${section_magic_begin_name})
add_custom_command_target(${section_magic_begin_name}_end
OUTPUT "${SWIFTLIB_DIR}/${arch_subdir}/swift_end.o"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${section_magic_end_name}.dir/swift_sections.S${CMAKE_C_OUTPUT_EXTENSION}" "${SWIFTLIB_DIR}/${arch_subdir}/swift_end.o"
DEPENDS ${section_magic_end_name})
list(APPEND object_target_list "${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o" "${SWIFTLIB_DIR}/${arch_subdir}/swift_end.o")
swift_install_in_component(compiler
FILES "swift.ld"
FILES "${SWIFTLIB_DIR}/${arch_subdir}/swift_begin.o" "${SWIFTLIB_DIR}/${arch_subdir}/swift_end.o"
DESTINATION "lib/swift/${arch_subdir}")
endforeach()
endif()
endforeach()
add_custom_target(section_magic ALL DEPENDS ${object_target_list})

View File

@@ -1,20 +0,0 @@
SECTIONS
{
.swift3_typeref : { *(.swift3_typeref) },
.swift3_reflstr : { *(.swift3_reflstr) },
.swift3_fieldmd : { *(.swift3_fieldmd) },
.swift3_assocty : { *(.swift3_assocty) },
.swift2_protocol_conformances :
{
.swift2_protocol_conformances_start = . ;
QUAD(SIZEOF(.swift2_protocol_conformances) - 8) ;
*(.swift2_protocol_conformances) ;
},
.swift2_type_metadata :
{
.swift2_type_metadata_start = . ;
QUAD(SIZEOF(.swift2_type_metadata) - 8) ;
*(.swift2_type_metadata) ;
}
}
INSERT AFTER .dtors

View File

@@ -0,0 +1,78 @@
//===-- stdlib/public/runtime/swift_sections.S ------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
///
/// \swift_sections.S
/// This file contains section markers for the computation of the location and
/// size of the conformances and metadata information for non-Darwin targets.
///
//===----------------------------------------------------------------------===//
#if !defined(SWIFT_BEGIN) && !defined(SWIFT_END)
#error "Define SWIFT_BEGIN or SWIFT_END to compile this file."
#endif
.macro define_sized_section name=1
#if defined(__arm__)
.section .\()\name, "aw", %progbits
#else
.section .\()\name, "aw", @progbits
#endif
.p2align 3
#if defined(SWIFT_BEGIN)
.globl .\()\name\()_start
.protected .\()\name\()_start
.\()\name\()_start:
#if defined(__BIG_ENDIAN__)
.long 0
.long .\()\name\()_end - .\()\name\()_start - 8
#else
.long .\()\name\()_end - .\()\name\()_start - 8
.long 0
#endif
#endif
#if defined(SWIFT_END)
.globl .\()\name\()_end
.protected .\()\name\()_end
.\()\name\()_end:
#endif
.endm
.macro define_simple_section name=1
#if defined(SWIFT_BEGIN)
#if defined(__arm__)
.section .\()\name, "aw", %progbits
#else
.section .\()\name, "aw", @progbits
#endif
// TODO .p2align 2 ?
.globl .\()\name\()_section
.protected .\()\name\()_section
.\()\name\()_section:
#endif
.endm
define_simple_section swift3_typeref
define_simple_section swift3_reflstr
define_simple_section swift3_fieldmd
define_simple_section swift3_assocty
define_sized_section swift2_protocol_conformances
define_sized_section swift2_type_metadata

View File

@@ -108,7 +108,6 @@
// LINUX-x86_64-DAG: -lswiftCore
// LINUX-x86_64-DAG: -L [[STDLIB_PATH:[^ ]+/lib/swift]]
// LINUX-x86_64-DAG: -Xlinker -rpath -Xlinker [[STDLIB_PATH]]
// LINUX-x86_64-DAG: -Xlinker -T /{{[^ ]+}}/linux/x86_64/swift.ld
// LINUX-x86_64-DAG: -F foo
// LINUX-x86_64-DAG: -framework bar
// LINUX-x86_64-DAG: -L baz
@@ -125,7 +124,6 @@
// LINUX-armv6-DAG: -L [[STDLIB_PATH:[^ ]+/lib/swift]]
// LINUX-armv6-DAG: --target=armv6-unknown-linux-gnueabihf
// LINUX-armv6-DAG: -Xlinker -rpath -Xlinker [[STDLIB_PATH]]
// LINUX-armv6-DAG: -Xlinker -T /{{[^ ]+}}/linux/armv6/swift.ld
// LINUX-armv6-DAG: -F foo
// LINUX-armv6-DAG: -framework bar
// LINUX-armv6-DAG: -L baz
@@ -142,7 +140,6 @@
// LINUX-armv7-DAG: -L [[STDLIB_PATH:[^ ]+/lib/swift]]
// LINUX-armv7-DAG: --target=armv7-unknown-linux-gnueabihf
// LINUX-armv7-DAG: -Xlinker -rpath -Xlinker [[STDLIB_PATH]]
// LINUX-armv7-DAG: -Xlinker -T /{{[^ ]+}}/linux/armv7/swift.ld
// LINUX-armv7-DAG: -F foo
// LINUX-armv7-DAG: -framework bar
// LINUX-armv7-DAG: -L baz

View File

@@ -1,14 +1,39 @@
// RUN: %swiftc_driver -driver-print-jobs -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | FileCheck %s
// RUN: env SDKROOT=%S/../Inputs/clang-importer-sdk %swiftc_driver_plain -g -driver-print-jobs %s 2>&1 | FileCheck %s
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | FileCheck %s --check-prefix OSX
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-unknown-linux-gnu -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | FileCheck %s --check-prefix LINUX
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-unknown-freebsd -g -sdk %S/../Inputs/clang-importer-sdk %s 2>&1 | FileCheck %s --check-prefix FREEBSD
// CHECK-NOT: warning: no such SDK:
// CHECK: bin/swift
// CHECK: Driver/sdk.swift
// CHECK: -sdk {{.*}}/Inputs/clang-importer-sdk
// CHECK-NEXT: bin/swift
// CHECK: -sdk {{.*}}/Inputs/clang-importer-sdk
// CHECK: bin/{{.+}} {{.*}}.o{{[ "]}}
// CHECK: {{-syslibroot|--sysroot}} {{.*}}/Inputs/clang-importer-sdk
// RUN: env SDKROOT=%S/../Inputs/clang-importer-sdk %swiftc_driver_plain -target x86_64-apple-macosx10.9 -g -driver-print-jobs %s 2>&1 | FileCheck %s --check-prefix OSX
// RUN: env SDKROOT=%S/../Inputs/clang-importer-sdk %swiftc_driver_plain -target x86_64-unknown-linux-gnu -g -driver-print-jobs %s 2>&1 | FileCheck %s --check-prefix LINUX
// RUN: env SDKROOT=%S/../Inputs/clang-importer-sdk %swiftc_driver_plain -target x86_64-unknown-freebsd -g -driver-print-jobs %s 2>&1 | FileCheck %s --check-prefix FREEBSD
// OSX-NOT: warning: no such SDK:
// OSX: bin/swift
// OSX: Driver/sdk.swift
// OSX: -sdk {{.*}}/Inputs/clang-importer-sdk
// OSX-NEXT: bin/swift
// OSX: -sdk {{.*}}/Inputs/clang-importer-sdk
// OSX: bin/{{.+}} {{.*}}.o{{[ "]}}
// OSX: {{-syslibroot|--sysroot}} {{.*}}/Inputs/clang-importer-sdk
// LINUX-NOT: warning: no such SDK:
// LINUX: bin/swift
// LINUX: Driver/sdk.swift
// LINUX: -sdk {{.*}}/Inputs/clang-importer-sdk
// LINUX-NEXT: bin/swift
// LINUX: -sdk {{.*}}/Inputs/clang-importer-sdk
// LINUX: bin/{{.+}} {{.*}}swift_begin.o
// LINUX: {{-syslibroot|--sysroot}} {{.*}}/Inputs/clang-importer-sdk
// LINUX: {{.*}}swift_end.o
// FREEBSD-NOT: warning: no such SDK:
// FREEBSD: bin/swift
// FREEBSD: Driver/sdk.swift
// FREEBSD: -sdk {{.*}}/Inputs/clang-importer-sdk
// FREEBSD-NEXT: bin/swift
// FREEBSD: -sdk {{.*}}/Inputs/clang-importer-sdk
// FREEBSD: bin/{{.+}} {{.*}}swift_begin.o
// FREEBSD: {{-syslibroot|--sysroot}} {{.*}}/Inputs/clang-importer-sdk
// FREEBSD: {{.*}}swift_end.o
// RUN: %swift_driver -driver-print-jobs -repl -sdk %S/Inputs/nonexistent-sdk 2>&1 | FileCheck %s --check-prefix=SDKWARNING
// RUN: %swift_driver -driver-print-jobs -sdk %S/Inputs/nonexistent-sdk 2>&1 | FileCheck %s --check-prefix=SDKWARNING

View File

@@ -31,6 +31,9 @@ function(add_swift_unittest test_dirname)
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
LINK_FLAGS " -fprofile-instr-generate -fcoverage-mapping")
endif()
elseif(${SWIFT_ENABLE_GOLD_LINKER})
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
LINK_FLAGS " -fuse-ld=gold")
endif()
endfunction()

View File

@@ -223,12 +223,18 @@ function set_deployment_target_based_options() {
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
linux-armv6)
# ARM targets require the gold linker
USE_GOLD_LINKER=1
SWIFT_HOST_VARIANT_ARCH="armv6"
;;
linux-armv7)
# ARM targets require the gold linker
USE_GOLD_LINKER=1
SWIFT_HOST_VARIANT_ARCH="armv7"
;;
linux-aarch64)
# ARM targets require the gold linker
USE_GOLD_LINKER=1
SWIFT_HOST_VARIANT_ARCH="aarch64"
;;
freebsd-x86_64)
@@ -1741,7 +1747,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
set -x
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}"
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}"
{ set +x; } 2>/dev/null
# XCTest builds itself and doesn't rely on cmake
@@ -1762,6 +1768,10 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
LIBDISPATCH_BUILD_ARGS="-DLIBDISPATCH_SOURCE_DIR=${LIBDISPATCH_SOURCE_DIR} -DLIBDISPATCH_BUILD_DIR=${LIBDISPATCH_BUILD_DIR}"
fi
if [[ "${USE_GOLD_LINKER}" ]]; then
SWIFT_USE_LINKER="-fuse-ld=gold"
fi
if [[ "${BUILD_NINJA}" ]]; then
NINJA_BUILD_DIR=$(build_directory build ninja)
NINJA_BIN="${NINJA_BUILD_DIR}/ninja"
@@ -2124,12 +2134,17 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
if [[ -z "${INSTALL_XCTEST}" ]] ; then
continue
fi
if [[ $(uname -s) == "Linux" ]]; then
LIB_TARGET="linux"
ARCH_FLAG="--arch=\"${SWIFT_HOST_VARIANT_ARCH}\""
fi
if [[ $(uname -s) == "FreeBSD" ]]; then
LIB_TARGET="freebsd"
ARCH_FLAG="--arch=\"${SWIFT_HOST_VARIANT_ARCH}\""
fi
if [[ $(uname -s) == "Darwin" ]]; then
LIB_TARGET="macosx"
ARCH_FLAG=""
fi
XCTEST_INSTALL_PREFIX="${INSTALL_DESTDIR}"/"${INSTALL_PREFIX}"/lib/swift/"${LIB_TARGET}"
echo "--- Installing ${product} ---"
@@ -2138,7 +2153,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
--build-dir="${build_dir}" \
--library-install-path="${XCTEST_INSTALL_PREFIX}" \
--module-install-path="${XCTEST_INSTALL_PREFIX}"/"${SWIFT_HOST_VARIANT_ARCH}" \
--swift-build-dir="${SWIFT_BUILD_PATH}"
--swift-build-dir="${SWIFT_BUILD_PATH}" ${ARCH_FLAG}
{ set +x; } 2>/dev/null
# As XCTest installation is self-contained, we break early here.