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,
@@ -1086,12 +1095,13 @@ final class BuildPlanTests: XCTestCase {
1086
1095
#if os(macOS)
1087
1096
XCTAssertEqual ( fooLinkArgs, [
1088
1097
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1089
- " -o " , " /path/to/build/debug/Foo " , " -module-name " , " Foo " , " -lBar-Baz " , " -emit-executable " ,
1090
- " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
1098
+ " -o " , " /path/to/build/debug/Foo " , " -module-name " , " Foo " , " -lBar-Baz " , " -emit-executable " ,
1099
+ " -Xlinker " , " -alias " , " -Xlinker " , " _Foo_main " , " -Xlinker " , " _main " ,
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, [
@@ -1108,6 +1118,7 @@ final class BuildPlanTests: XCTestCase {
1108
1118
XCTAssertEqual ( fooLinkArgs, [
1109
1119
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1110
1120
" -o " , " /path/to/build/debug/Foo " , " -module-name " , " Foo " , " -lBar-Baz " , " -emit-executable " ,
1121
+ " -Xlinker " , " -alias " , " -Xlinker " , " _Foo_main " , " -Xlinker " , " _main " ,
1111
1122
" -Xlinker " , " -rpath=$ORIGIN " ,
1112
1123
" @/path/to/build/debug/Foo.product/Objects.LinkFileList " ,
1113
1124
" -target " , defaultTargetTriple,
@@ -1615,6 +1626,7 @@ final class BuildPlanTests: XCTestCase {
1615
1626
" /fake/path/to/swiftc " ,
1616
1627
" -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/exe.exe " ,
1617
1628
" -module-name " , " exe " , " -emit-executable " ,
1629
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
1618
1630
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
1619
1631
" -target " , " x86_64-unknown-windows-msvc " ,
1620
1632
] )
@@ -1692,6 +1704,7 @@ final class BuildPlanTests: XCTestCase {
1692
1704
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1693
1705
" -o " , " /path/to/build/debug/app.wasm " ,
1694
1706
" -module-name " , " app " , " -static-stdlib " , " -emit-executable " ,
1707
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=app_main " ,
1695
1708
" @/path/to/build/debug/app.product/Objects.LinkFileList " ,
1696
1709
" -target " , " wasm32-unknown-wasi "
1697
1710
]
@@ -2340,10 +2353,10 @@ final class BuildPlanTests: XCTestCase {
2340
2353
XCTAssertMatch ( contents, . contains( """
2341
2354
" /path/to/build/debug/exe.build/exe.swiftmodule.o " :
2342
2355
tool: shell
2343
- inputs: [ " /path/to/build/debug/exe.build/exe. swiftmodule " ]
2356
+ inputs: [ " /path/to/build/debug/exe.swiftmodule " ]
2344
2357
outputs: [ " /path/to/build/debug/exe.build/exe.swiftmodule.o " ]
2345
2358
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 " ]
2359
+ 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
2360
""" ) )
2348
2361
XCTAssertMatch ( contents, . contains( """
2349
2362
" /path/to/build/debug/lib.build/lib.swiftmodule.o " :
0 commit comments