Skip to content

Replace the --defsym linker argument with an alias in code #1011

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
Jun 20, 2017
Merged
Show file tree
Hide file tree
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
18 changes: 7 additions & 11 deletions CoreFoundation/Base.subproj/CFInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,21 +334,17 @@ CF_PRIVATE Boolean __CFProcessIsRestricted();
#define STACK_BUFFER_DECL(T, N, C) T N[C]
#endif

#ifdef __ANDROID__
// Avoids crashes on Android
// https://bugs.swift.org/browse/SR-2587
// https://bugs.swift.org/browse/SR-2588
// Seemed to be a linker/relocation? problem.
// CFStrings using CONST_STRING_DECL() were not working
// Applies reference to _NSCFConstantString's isa here
// rather than using a linker option to create an alias.
#define __CFConstantStringClassReference _T010Foundation19_NSCFConstantStringCN
#endif

CF_EXPORT void * __CFConstantStringClassReferencePtr;

#if DEPLOYMENT_RUNTIME_SWIFT

#if TARGET_OS_MAC
#define __CFConstantStringClassReference _T015SwiftFoundation19_NSCFConstantStringCN
#else
#define __CFConstantStringClassReference _T010Foundation19_NSCFConstantStringCN
#endif

CF_EXPORT void * __CFConstantStringClassReferencePtr;
CF_EXPORT void *__CFConstantStringClassReference[];

#if __CF_BIG_ENDIAN__
Expand Down
5 changes: 0 additions & 5 deletions CoreFoundation/Base.subproj/SymbolAliases
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@


# This is specific to Swift open source; Foundation's NSCFConstantString is used as our constant string class reference
__T015SwiftFoundation19_NSCFConstantStringCN ___CFConstantStringClassReference

_kCFCalendarIdentifierBuddhist _kCFBuddhistCalendar
_kCFCalendarIdentifierChinese _kCFChineseCalendar
_kCFCalendarIdentifierGregorian _kCFGregorianCalendar
Expand Down
4 changes: 2 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
swift_cflags = ['-DDEPLOYMENT_RUNTIME_SWIFT']
if Configuration.current.target.sdk == OSType.Linux:
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -DCF_CHARACTERSET_DATA_DIR="CoreFoundation/CharacterSets"'
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -Wl,@./CoreFoundation/linux.ld -lswiftGlibc `${PKG_CONFIG} icu-uc icu-i18n --libs` -Wl,-defsym,__CFConstantStringClassReference=_T010Foundation19_NSCFConstantStringCN -Wl,-Bsymbolic '
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -Wl,@./CoreFoundation/linux.ld -lswiftGlibc `${PKG_CONFIG} icu-uc icu-i18n --libs` -Wl,-Bsymbolic '
Configuration.current.requires_pkg_config = True
elif Configuration.current.target.sdk == OSType.FreeBSD:
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_FREEBSD -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/local/include/curl '
Expand All @@ -26,7 +26,7 @@
foundation.LDFLAGS = '-licucore -twolevel_namespace -Wl,-alias_list,CoreFoundation/Base.subproj/DarwinSymbolAliases -sectcreate __UNICODE __csbitmaps CoreFoundation/CharacterSets/CFCharacterSetBitmaps.bitmap -sectcreate __UNICODE __properties CoreFoundation/CharacterSets/CFUniCharPropertyDatabase.data -sectcreate __UNICODE __data CoreFoundation/CharacterSets/CFUnicodeData-L.mapping -segprot __UNICODE r r '
elif Configuration.current.target.sdk == OSType.Win32 and Configuration.current.target.environ == EnvironmentType.Cygnus:
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -mcmodel=large '
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -lswiftGlibc `icu-config --ldflags` -Wl,-defsym,__CFConstantStringClassReference=_T010Foundation19_NSCFConstantStringCN,--allow-multiple-definition '
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -lswiftGlibc `icu-config --ldflags` -Wl,--allow-multiple-definition '
swift_cflags += ['-DCYGWIN']

if Configuration.current.build_mode == Configuration.Debug:
Expand Down