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,
@@ -779,16 +783,18 @@ final class BuildPlanTests: XCTestCase {
779
783
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
780
784
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
781
785
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
786
+ " -Xlinker " , " -alias " , " -Xlinker " , " _exe_main " , " -Xlinker " , " _main " ,
782
787
" -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
783
788
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
784
789
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
785
790
" -target " , " x86_64-apple-macosx10.10 " ,
786
- " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.build/exe. swiftmodule " ,
791
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " ,
787
792
] )
788
793
#else
789
794
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
790
795
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
791
796
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
797
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
792
798
" -Xlinker " , " -rpath=$ORIGIN " ,
793
799
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
794
800
" -target " , defaultTargetTriple,
@@ -989,16 +995,18 @@ final class BuildPlanTests: XCTestCase {
989
995
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
990
996
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
991
997
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
998
+ " -Xlinker " , " -alias " , " -Xlinker " , " _exe_main " , " -Xlinker " , " _main " ,
992
999
" -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
993
1000
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
994
1001
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
995
1002
" -target " , " x86_64-apple-macosx10.10 " ,
996
- " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.build/exe. swiftmodule " ,
1003
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " ,
997
1004
] )
998
1005
#else
999
1006
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
1000
1007
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1001
1008
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
1009
+ " -Xlinker " , " --defsym " , " -Xlinker " , " main=exe_main " ,
1002
1010
" -Xlinker " , " -rpath=$ORIGIN " ,
1003
1011
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
1004
1012
" -target " , defaultTargetTriple,
@@ -1086,12 +1094,13 @@ final class BuildPlanTests: XCTestCase {
1086
1094
#if os(macOS)
1087
1095
XCTAssertEqual ( fooLinkArgs, [
1088
1096
" /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 " ,
1097
+ " -o " , " /path/to/build/debug/Foo " , " -module-name " , " Foo " , " -lBar-Baz " , " -emit-executable " ,
1098
+ " -Xlinker " , " -alias " , " -Xlinker " , " _Foo_main " , " -Xlinker " , " _main " ,
1099
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
1091
1100
" @/path/to/build/debug/Foo.product/Objects.LinkFileList " ,
1092
1101
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
1093
1102
" -target " , " x86_64-apple-macosx10.10 " ,
1094
- " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Foo.build/Foo. swiftmodule "
1103
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Foo.swiftmodule "
1095
1104
] )
1096
1105
1097
1106
XCTAssertEqual ( barLinkArgs, [
@@ -1108,6 +1117,7 @@ final class BuildPlanTests: XCTestCase {
1108
1117
XCTAssertEqual ( fooLinkArgs, [
1109
1118
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
1110
1119
" -o " , " /path/to/build/debug/Foo " , " -module-name " , " Foo " , " -lBar-Baz " , " -emit-executable " ,
1120
+ " -Xlinker " , " -alias " , " -Xlinker " , " _Foo_main " , " -Xlinker " , " _main " ,
1111
1121
" -Xlinker " , " -rpath=$ORIGIN " ,
1112
1122
" @/path/to/build/debug/Foo.product/Objects.LinkFileList " ,
1113
1123
" -target " , defaultTargetTriple,
@@ -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 " :
0 commit comments