Skip to content

Commit 13aa8ec

Browse files
committed
Replace the --defsym linker argument with an alias in code
- This has the same effect as the --defsym=__CFConstantStringClassReference=_T010Foundation19_NSCFConstantStringCN option but does it in code which allows simplifying the linker arguments. - Unify the Linux and Android #define and add a seperate one for macOS. - Remove the entry from CoreFoundation/Base.subproj/SymbolAliases now that it is set in code.
1 parent d8f78f9 commit 13aa8ec

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

CoreFoundation/Base.subproj/CFInternal.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,21 +334,17 @@ CF_PRIVATE Boolean __CFProcessIsRestricted();
334334
#define STACK_BUFFER_DECL(T, N, C) T N[C]
335335
#endif
336336

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

348-
CF_EXPORT void * __CFConstantStringClassReferencePtr;
349338

350339
#if DEPLOYMENT_RUNTIME_SWIFT
351340

341+
#if TARGET_OS_MAC
342+
#define __CFConstantStringClassReference _T015SwiftFoundation19_NSCFConstantStringCN
343+
#else
344+
#define __CFConstantStringClassReference _T010Foundation19_NSCFConstantStringCN
345+
#endif
346+
347+
CF_EXPORT void * __CFConstantStringClassReferencePtr;
352348
CF_EXPORT void *__CFConstantStringClassReference[];
353349

354350
#if __CF_BIG_ENDIAN__

CoreFoundation/Base.subproj/SymbolAliases

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
3-
# This is specific to Swift open source; Foundation's NSCFConstantString is used as our constant string class reference
4-
__T015SwiftFoundation19_NSCFConstantStringCN ___CFConstantStringClassReference
5-
61
_kCFCalendarIdentifierBuddhist _kCFBuddhistCalendar
72
_kCFCalendarIdentifierChinese _kCFChineseCalendar
83
_kCFCalendarIdentifierGregorian _kCFGregorianCalendar

build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
swift_cflags = ['-DDEPLOYMENT_RUNTIME_SWIFT']
1717
if Configuration.current.target.sdk == OSType.Linux:
1818
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -DCF_CHARACTERSET_DATA_DIR="CoreFoundation/CharacterSets"'
19-
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -Wl,@./CoreFoundation/linux.ld -lswiftGlibc `${PKG_CONFIG} icu-uc icu-i18n --libs` -Wl,-defsym,__CFConstantStringClassReference=_T010Foundation19_NSCFConstantStringCN -Wl,-Bsymbolic '
19+
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -Wl,@./CoreFoundation/linux.ld -lswiftGlibc `${PKG_CONFIG} icu-uc icu-i18n --libs` -Wl,-Bsymbolic '
2020
Configuration.current.requires_pkg_config = True
2121
elif Configuration.current.target.sdk == OSType.FreeBSD:
2222
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_FREEBSD -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/local/include/curl '
@@ -26,7 +26,7 @@
2626
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 '
2727
elif Configuration.current.target.sdk == OSType.Win32 and Configuration.current.target.environ == EnvironmentType.Cygnus:
2828
foundation.CFLAGS = '-DDEPLOYMENT_TARGET_LINUX -D_GNU_SOURCE -mcmodel=large '
29-
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -lswiftGlibc `icu-config --ldflags` -Wl,-defsym,__CFConstantStringClassReference=_T010Foundation19_NSCFConstantStringCN,--allow-multiple-definition '
29+
foundation.LDFLAGS = '${SWIFT_USE_LINKER} -lswiftGlibc `icu-config --ldflags` -Wl,--allow-multiple-definition '
3030
swift_cflags += ['-DCYGWIN']
3131

3232
if Configuration.current.build_mode == Configuration.Debug:

0 commit comments

Comments
 (0)