From 86e5bbffd757c211c062acef6c244ec94f5db668 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 9 Oct 2019 22:41:38 +0200 Subject: Patch lld to have a more sensible kill-at implementation Lift some code from llvm-dlltool, the lld code is meant to follow what gnu ld does but that's not much useful for our purposes. Also use the `--kill-at` option when generating the .lib files out of mingw's .def files: this way our building process closely matches the one use by the upstream and now finally generates files that allow both C code and Zig code to link. --- src/link.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/link.cpp') diff --git a/src/link.cpp b/src/link.cpp index 1310210cba..f7ae4a8400 100644 --- a/src/link.cpp +++ b/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)) { -- cgit v1.2.3