@@ -77,31 +77,43 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
77
77
Args.AddAllArgs (CmdArgs, options::OPT_u);
78
78
ToolChain.AddFilePathLibArgs (Args, CmdArgs);
79
79
80
- const char *Crt1 = " crt1.o" ;
80
+ bool IsCommand = true ;
81
+ const char *Crt1;
81
82
const char *Entry = nullptr ;
82
83
83
- // If crt1-command.o exists, it supports new-style commands, so use it.
84
- // Otherwise, use the old crt1.o. This is a temporary transition measure.
85
- // Once WASI libc no longer needs to support LLVM versions which lack
86
- // support for new-style command, it can make crt1.o the same as
87
- // crt1-command.o. And once LLVM no longer needs to support WASI libc
88
- // versions before that, it can switch to using crt1-command.o.
89
- if (ToolChain.GetFilePath (" crt1-command.o" ) != " crt1-command.o" )
90
- Crt1 = " crt1-command.o" ;
84
+ // When -shared is specified, use the reactor exec model unless
85
+ // specified otherwise.
86
+ if (Args.hasArg (options::OPT_shared))
87
+ IsCommand = false ;
91
88
92
89
if (const Arg *A = Args.getLastArg (options::OPT_mexec_model_EQ)) {
93
90
StringRef CM = A->getValue ();
94
91
if (CM == " command" ) {
95
- // Use default values.
92
+ IsCommand = true ;
96
93
} else if (CM == " reactor" ) {
97
- Crt1 = " crt1-reactor.o" ;
98
- Entry = " _initialize" ;
94
+ IsCommand = false ;
99
95
} else {
100
96
ToolChain.getDriver ().Diag (diag::err_drv_invalid_argument_to_option)
101
97
<< CM << A->getOption ().getName ();
102
98
}
103
99
}
104
- if (!Args.hasArg (options::OPT_nostdlib, options::OPT_nostartfiles, options::OPT_shared))
100
+
101
+ if (IsCommand) {
102
+ // If crt1-command.o exists, it supports new-style commands, so use it.
103
+ // Otherwise, use the old crt1.o. This is a temporary transition measure.
104
+ // Once WASI libc no longer needs to support LLVM versions which lack
105
+ // support for new-style command, it can make crt1.o the same as
106
+ // crt1-command.o. And once LLVM no longer needs to support WASI libc
107
+ // versions before that, it can switch to using crt1-command.o.
108
+ Crt1 = " crt1.o" ;
109
+ if (ToolChain.GetFilePath (" crt1-command.o" ) != " crt1-command.o" )
110
+ Crt1 = " crt1-command.o" ;
111
+ } else {
112
+ Crt1 = " crt1-reactor.o" ;
113
+ Entry = " _initialize" ;
114
+ }
115
+
116
+ if (!Args.hasArg (options::OPT_nostdlib, options::OPT_nostartfiles))
105
117
CmdArgs.push_back (Args.MakeArgString (ToolChain.GetFilePath (Crt1)));
106
118
if (Entry) {
107
119
CmdArgs.push_back (Args.MakeArgString (" --entry" ));
0 commit comments