diff --git a/install-wrappers.sh b/install-wrappers.sh index bfa0909..91ad6ce 100755 --- a/install-wrappers.sh +++ b/install-wrappers.sh @@ -70,7 +70,6 @@ if [ -n "$HOST" ]; then 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/windres-wrapper.c -o "$PREFIX/bin/windres-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 @@ -94,13 +93,9 @@ for arch in $ARCHS; do fi ln -sf $link_target$EXEEXT $arch-w64-$target_os-$exec$EXEEXT || true done - if [ -f "llvm-windres$EXEEXT" ]; then - # windres can't use llvm-wrapper, as that loses the original - # target arch prefix. - ln -sf llvm-windres$EXEEXT $arch-w64-$target_os-windres$EXEEXT - else - ln -sf windres-wrapper$EXEEXT $arch-w64-$target_os-windres$EXEEXT - fi + # windres 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 for exec in ld objdump; do ln -sf $exec-wrapper.sh $arch-w64-$target_os-$exec diff --git a/wrappers/windres-wrapper.c b/wrappers/windres-wrapper.c deleted file mode 100644 index f22daae..0000000 --- a/wrappers/windres-wrapper.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (c) 2018 Josh de Kock - * 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 - -#include - -#ifdef _WIN32 -#else -#define _tspawnvp_escape _spawnvp - -#include -#include -#include - -#define _P_WAIT 0 -static int _spawnvp(int mode, const char *filename, const char * const *argv) { - pid_t pid; - if (!(pid = fork())) { - execvp(filename, (char **) argv); - perror(filename); - exit(1); - } - int stat = 0; - if (waitpid(pid, &stat, 0) == -1) - return -1; - if (WIFEXITED(stat)) - return WEXITSTATUS(stat); - errno = EIO; - return -1; -} -#endif - -// GNU binutils windres seem to require an extra level of escaping of -// -D options to the preprocessor, which we need to undo here. -// For defines that produce quoted strings, this windres frontend is -// called with parameters like this: -DSTRING=\\\"1.2.3\\\" -static const TCHAR *unescape_cpp(const TCHAR *str) { - TCHAR *out = _tcsdup(str); - int len = _tcslen(str); - int i, outpos = 0; - for (i = 0; i < len - 1; i++) { - if (str[i] == '\\' && str[i + 1] == '"') - continue; - out[outpos++] = str[i]; - } - while (i < len) - out[outpos++] = str[i++]; - out[outpos++] = '\0'; - return out; -} - -static int split_args(const TCHAR *str, const TCHAR **args, int *num_args, int max_args) { - int len = _tcslen(str); - TCHAR *out = _tcsdup(str); - int i, outpos = 0; - int arg = num_args ? *num_args : 0; - int inquote = 0; - if (!args) - max_args = INT_MAX; - for (i = 0; i < len; i++) { - if (str[i] == '\\') { - if (i + 1 < len) - out[outpos++] = str[++i]; - else - fprintf(stderr, "Unterminated escape\n"); - continue; - } - if (str[i] == '"') { - inquote = !inquote; - continue; - } - if (str[i] == ' ' && !inquote) { - out[outpos++] = '\0'; - if (arg < max_args) { - if (args) - args[arg] = _tcsdup(out); - arg++; - } else - fprintf(stderr, "Too many options split\n"); - outpos = 0; - continue; - } - out[outpos++] = str[i]; - } - if (inquote) - fprintf(stderr, "Unterminated quote\n"); - if (outpos > 0) { - out[outpos++] = '\0'; - if (arg < max_args) { - if (args) - args[arg] = _tcsdup(out); - arg++; - } else - fprintf(stderr, "Too many options split\n"); - } - if (num_args) { - *num_args = arg; - arg -= *num_args; - } - return arg; -} - -static void print_version(void) { - printf( -"version: LLVM windres (GNU windres compatible) 0.1\n" - ); - exit(0); -} - -static void print_help(void) { - printf( -"usage: llvm-windres