From 42d2eb7346eb392d9d0b25e5c083f92020dbd757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 16 Sep 2021 15:24:56 +0300 Subject: [PATCH] wrappers: Remove the dlltool wrapper Since LLVM 13, llvm-dlltool can imply the target architecture from a triple prefix on the tool name, so there's no more need for a wrapper. The *-dlltool tools are now symlinks to the main llvm-dlltool executable. In the Windows distribution, the *-dlltool.exe used to be copies of dlltool-wrapper.exe (which is small; 15 KB). Now they will instead be copies of llvm-dlltool.exe. Luckily, thanks to building with -DLLVM_LINK_LLVM_DYLIB=ON by default, llvm-dlltool.exe is only a mere 65 KB, while it used to be much larger, e.g. around 11 MB in older releases. --- install-wrappers.sh | 5 ++- wrappers/dlltool-wrapper.c | 68 -------------------------------------- 2 files changed, 2 insertions(+), 71 deletions(-) delete mode 100644 wrappers/dlltool-wrapper.c diff --git a/install-wrappers.sh b/install-wrappers.sh index 247e7eb..9165d19 100755 --- a/install-wrappers.sh +++ b/install-wrappers.sh @@ -69,7 +69,6 @@ if [ -n "$HOST" ]; then done fi $CC wrappers/clang-target-wrapper.c -o "$PREFIX/bin/clang-target-wrapper$EXEEXT" -O2 -Wl,-s $WRAPPER_FLAGS -$CC wrappers/dlltool-wrapper.c -o "$PREFIX/bin/dlltool-wrapper$EXEEXT" -O2 -Wl,-s $WRAPPER_FLAGS $CC wrappers/llvm-wrapper.c -o "$PREFIX/bin/llvm-wrapper$EXEEXT" -O2 -Wl,-s $WRAPPER_FLAGS if [ -n "$EXEEXT" ]; then # For Windows, we should prefer the executable wrapper, which also works @@ -93,10 +92,10 @@ for arch in $ARCHS; do fi ln -sf $link_target$EXEEXT $arch-w64-$target_os-$exec$EXEEXT || true done - # windres can't use llvm-wrapper, as that loses the original + # windres and dlltool can't use llvm-wrapper, as that loses the original # target arch prefix. ln -sf llvm-windres$EXEEXT $arch-w64-$target_os-windres$EXEEXT - ln -sf dlltool-wrapper$EXEEXT $arch-w64-$target_os-dlltool$EXEEXT + ln -sf llvm-dlltool$EXEEXT $arch-w64-$target_os-dlltool$EXEEXT for exec in ld objdump; do ln -sf $exec-wrapper.sh $arch-w64-$target_os-$exec done diff --git a/wrappers/dlltool-wrapper.c b/wrappers/dlltool-wrapper.c deleted file mode 100644 index 8c770a6..0000000 --- a/wrappers/dlltool-wrapper.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2018 Martin Storsjo - * - * This file is part of llvm-mingw. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "native-wrapper.h" - -#ifndef DEFAULT_TARGET -#define DEFAULT_TARGET "x86_64-w64-mingw32" -#endif - -int _tmain(int argc, TCHAR* argv[]) { - const TCHAR *dir; - const TCHAR *target; - split_argv(argv[0], &dir, NULL, &target, NULL); - if (!target) - target = _T(DEFAULT_TARGET); - TCHAR *arch = _tcsdup(target); - TCHAR *dash = _tcschr(arch, '-'); - if (dash) - *dash = '\0'; - - int max_arg = argc + 2; - const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv)); - int arg = 0; - exec_argv[arg++] = concat(dir, _T("llvm-dlltool")); - - if (!_tcscmp(arch, _T("i686"))) { - exec_argv[arg++] = _T("-m"); - exec_argv[arg++] = _T("i386"); - } else if (!_tcscmp(arch, _T("x86_64"))) { - exec_argv[arg++] = _T("-m"); - exec_argv[arg++] = _T("i386:x86-64"); - } else if (!_tcscmp(arch, _T("armv7"))) { - exec_argv[arg++] = _T("-m"); - exec_argv[arg++] = _T("arm"); - } else if (!_tcscmp(arch, _T("aarch64"))) { - exec_argv[arg++] = _T("-m"); - exec_argv[arg++] = _T("arm64"); - } else { - _ftprintf(stderr, _T("Arch "TS" unsupported\n"), arch); - return 1; - } - - for (int i = 1; i < argc; i++) - exec_argv[arg++] = argv[i]; - - exec_argv[arg] = NULL; - if (arg > max_arg) { - fprintf(stderr, "Too many options added\n"); - abort(); - } - - return run_final(exec_argv[0], exec_argv); -}