Commit 86e5bbffd7
Changed files (2)
deps
lld
COFF
src
deps/lld/COFF/DriverUtils.cpp
@@ -638,10 +638,18 @@ void fixupExports() {
if (config->killAt && config->machine == I386) {
for (Export &e : config->exports) {
- e.name = killAt(e.name, true);
- e.exportName = killAt(e.exportName, false);
- e.extName = killAt(e.extName, true);
- e.symbolName = killAt(e.symbolName, true);
+ if (!e.name.empty() && e.name[0] == '?')
+ continue;
+ e.symbolName = e.name;
+ // Trim off the trailing decoration. Symbols will always have a
+ // starting prefix here (either _ for cdecl/stdcall, @ for fastcall
+ // or ? for C++ functions). Vectorcall functions won't have any
+ // fixed prefix, but the function base name will still be at least
+ // one char.
+ e.name = e.name.substr(0, e.name.find('@', 1));
+ // By making sure E.SymbolName != E.Name for decorated symbols,
+ // writeImportLibrary writes these symbols with the type
+ // IMPORT_NAME_UNDECORATE.
}
}
src/link.cpp
@@ -2057,10 +2057,19 @@ static const char *get_def_lib(CodeGen *parent, const char *name, Buf *def_in_fi
args.resize(0);
args.append("link");
coff_append_machine_arg(parent, &args);
+ args.append("-lldmingw");
+ args.append("-kill-at");
args.append(buf_ptr(buf_sprintf("-DEF:%s", buf_ptr(def_final_path))));
args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(lib_final_path))));
+ if (parent->verbose_link) {
+ for (size_t i = 0; i < args.length; i += 1) {
+ fprintf(stderr, "%s ", args.at(i));
+ }
+ fprintf(stderr, "\n");
+ }
+
Buf diag = BUF_INIT;
ZigLLVM_ObjectFormatType target_ofmt = target_object_format(parent->zig_target);
if (!zig_lld_link(target_ofmt, args.items, args.length, &diag)) {