1
1
/*
2
2
This source file is part of the Swift.org open source project
3
3
4
- Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
4
+ Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
5
5
Licensed under Apache License v2.0 with Runtime Library Exception
6
6
7
7
See http://swift.org/LICENSE.txt for license information
@@ -138,18 +138,20 @@ final class BuildPlanTests: XCTestCase {
138
138
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
139
139
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " ,
140
140
" -emit-executable " ,
141
+ " -Xlinker " , " -alias " , " -Xlinker " , " _exe_main " , " -Xlinker " , " _main " ,
141
142
" -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
142
143
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
143
144
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
144
145
" -target " , " x86_64-apple-macosx10.10 " , " -Xlinker " , " -add_ast_path " ,
145
- " -Xlinker " , " /path/to/build/debug/exe.build/exe. swiftmodule " , " -Xlinker " , " -add_ast_path " ,
146
+ " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " , " -Xlinker " , " -add_ast_path " ,
146
147
" -Xlinker " , " /path/to/build/debug/lib.swiftmodule " ,
147
148
]
148
149
#else
149
150
let linkArguments = [
150
151
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
151
152
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " ,
152
153
" -static-stdlib " , " -emit-executable " ,
154
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
153
155
" -Xlinker " , " -rpath=$ORIGIN " ,
154
156
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
155
157
" -target " , defaultTargetTriple,
@@ -450,6 +452,7 @@ final class BuildPlanTests: XCTestCase {
450
452
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
451
453
" /fake/path/to/swiftc " , " -g " , " -L " , " /path/to/build/release " ,
452
454
" -o " , " /path/to/build/release/exe " , " -module-name " , " exe " , " -emit-executable " ,
455
+ " -Xlinker " , " -alias " , " -Xlinker " , " _exe_main " , " -Xlinker " , " _main " ,
453
456
" -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
454
457
" @/path/to/build/release/exe.product/Objects.LinkFileList " ,
455
458
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
@@ -459,6 +462,7 @@ final class BuildPlanTests: XCTestCase {
459
462
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
460
463
" /fake/path/to/swiftc " , " -g " , " -L " , " /path/to/build/release " ,
461
464
" -o " , " /path/to/build/release/exe " , " -module-name " , " exe " , " -emit-executable " ,
465
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
462
466
" -Xlinker " , " -rpath=$ORIGIN " ,
463
467
" @/path/to/build/release/exe.product/Objects.LinkFileList " ,
464
468
" -target " , defaultTargetTriple,
@@ -712,6 +716,7 @@ final class BuildPlanTests: XCTestCase {
712
716
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
713
717
" /fake/path/to/swiftc " , " -lstdc++ " , " -L " , " /path/to/build/debug " , " -o " ,
714
718
" /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
719
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
715
720
" -Xlinker " , " -rpath=$ORIGIN " ,
716
721
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
717
722
" -runtime-compatibility-version " , " none " ,
@@ -779,16 +784,18 @@ final class BuildPlanTests: XCTestCase {
779
784
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
780
785
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
781
786
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
787
+ " -Xlinker " , " -alias " , " -Xlinker " , " _exe_main " , " -Xlinker " , " _main " ,
782
788
" -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
783
789
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
784
790
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
785
791
" -target " , " x86_64-apple-macosx10.10 " ,
786
- " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.build/exe. swiftmodule " ,
792
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " ,
787
793
] )
788
794
#else
789
795
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
790
796
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
791
797
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
798
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
792
799
" -Xlinker " , " -rpath=$ORIGIN " ,
793
800
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
794
801
" -target " , defaultTargetTriple,
@@ -989,16 +996,18 @@ final class BuildPlanTests: XCTestCase {
989
996
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
990
997
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
991
998
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
999
+ " -Xlinker " , " -alias " , " -Xlinker " , " _exe_main " , " -Xlinker " , " _main " ,
992
1000
" -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
993
1001
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
994
1002
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
995
1003
" -target " , " x86_64-apple-macosx10.10 " ,
996
- " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.build/exe. swiftmodule " ,
1004
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " ,
997
1005
] )
998
1006
#else
999
1007
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
1000
1008
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1001
1009
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
1010
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
1002
1011
" -Xlinker " , " -rpath=$ORIGIN " ,
1003
1012
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
1004
1013
" -target " , defaultTargetTriple,
@@ -1087,11 +1096,12 @@ final class BuildPlanTests: XCTestCase {
1087
1096
XCTAssertEqual ( fooLinkArgs, [
1088
1097
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1089
1098
" -o " , " /path/to/build/debug/Foo " , " -module-name " , " Foo " , " -lBar-Baz " , " -emit-executable " ,
1099
+ " -Xlinker " , " -alias " , " -Xlinker " , " _Foo_main " , " -Xlinker " , " _main " ,
1090
1100
" -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
1091
1101
" @/path/to/build/debug/Foo.product/Objects.LinkFileList " ,
1092
1102
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
1093
1103
" -target " , " x86_64-apple-macosx10.10 " ,
1094
- " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Foo.build/Foo. swiftmodule "
1104
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Foo.swiftmodule "
1095
1105
] )
1096
1106
1097
1107
XCTAssertEqual ( barLinkArgs, [
@@ -1615,6 +1625,7 @@ final class BuildPlanTests: XCTestCase {
1615
1625
" /fake/path/to/swiftc " ,
1616
1626
" -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/exe.exe " ,
1617
1627
" -module-name " , " exe " , " -emit-executable " ,
1628
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
1618
1629
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
1619
1630
" -target " , " x86_64-unknown-windows-msvc " ,
1620
1631
] )
@@ -1692,6 +1703,7 @@ final class BuildPlanTests: XCTestCase {
1692
1703
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1693
1704
" -o " , " /path/to/build/debug/app.wasm " ,
1694
1705
" -module-name " , " app " , " -static-stdlib " , " -emit-executable " ,
1706
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=app_main " ,
1695
1707
" @/path/to/build/debug/app.product/Objects.LinkFileList " ,
1696
1708
" -target " , " wasm32-unknown-wasi "
1697
1709
]
@@ -2340,10 +2352,10 @@ final class BuildPlanTests: XCTestCase {
2340
2352
XCTAssertMatch ( contents, . contains( """
2341
2353
" /path/to/build/debug/exe.build/exe.swiftmodule.o " :
2342
2354
tool: shell
2343
- inputs: [ " /path/to/build/debug/exe.build/exe. swiftmodule " ]
2355
+ inputs: [ " /path/to/build/debug/exe.swiftmodule " ]
2344
2356
outputs: [ " /path/to/build/debug/exe.build/exe.swiftmodule.o " ]
2345
2357
description: " Wrapping AST for exe for debugging "
2346
- args: [ " /fake/path/to/swiftc " , " -modulewrap " , " /path/to/build/debug/exe.build/exe. swiftmodule " , " -o " , " /path/to/build/debug/exe.build/exe.swiftmodule.o " , " -target " , " x86_64-unknown-linux-gnu " ]
2358
+ args: [ " /fake/path/to/swiftc " , " -modulewrap " , " /path/to/build/debug/exe.swiftmodule " , " -o " , " /path/to/build/debug/exe.build/exe.swiftmodule.o " , " -target " , " x86_64-unknown-linux-gnu " ]
2347
2359
""" ) )
2348
2360
XCTAssertMatch ( contents, . contains( """
2349
2361
" /path/to/build/debug/lib.build/lib.swiftmodule.o " :
@@ -2831,3 +2843,4 @@ fileprivate extension TSCUtility.Triple {
2831
2843
static let windows = try ! Triple ( " x86_64-unknown-windows-msvc " )
2832
2844
static let wasi = try ! Triple ( " wasm32-unknown-wasi " )
2833
2845
}
2846
+
0 commit comments