$NetBSD$ Support Darwin/aarch64, from https://github.com/Homebrew/formula-patches. --- gcc/exec-tool.in +++ gcc/exec-tool.in @@ -23,6 +23,8 @@ ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@" ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@" ORIGINAL_LD_BFD_FOR_TARGET="@ORIGINAL_LD_BFD_FOR_TARGET@" ORIGINAL_LD_GOLD_FOR_TARGET="@ORIGINAL_LD_GOLD_FOR_TARGET@" +ORIGINAL_LLD_FOR_TARGET="@ORIGINAL_LLD_FOR_TARGET@" +ORIGINAL_CLASSIC_LD_FOR_TARGET="@ORIGINAL_CLASSIC_LD_FOR_TARGET@" ORIGINAL_PLUGIN_LD_FOR_TARGET="@ORIGINAL_PLUGIN_LD_FOR_TARGET@" ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@" ORIGINAL_DSYMUTIL_FOR_TARGET="@ORIGINAL_DSYMUTIL_FOR_TARGET@" @@ -39,24 +41,41 @@ case "$invoked" in dir=gas ;; collect-ld) - # Check -fuse-ld=bfd and -fuse-ld=gold - case " $* " in - *\ -fuse-ld=bfd\ *) - original=$ORIGINAL_LD_BFD_FOR_TARGET - ;; - *\ -fuse-ld=gold\ *) - original=$ORIGINAL_LD_GOLD_FOR_TARGET - ;; - *) - # when using a linker plugin, gcc will always pass '-plugin' as the - # first or second option to the linker. - if test x"$1" = "x-plugin" || test x"$2" = "x-plugin"; then - original=$ORIGINAL_PLUGIN_LD_FOR_TARGET - else - original=$ORIGINAL_LD_FOR_TARGET - fi - ;; - esac + # when using a linker plugin, gcc will always pass '-plugin' as the + # first or second option to the linker. + if test x"$1" = "x-plugin" || test x"$2" = "x-plugin"; then + original=$ORIGINAL_PLUGIN_LD_FOR_TARGET + else + original=$ORIGINAL_LD_FOR_TARGET + fi + # Check -fuse-ld=bfd, -fuse-ld=gold and -fuse-ld=classic + # Remove -fuse-ld=classic from the command line + for arg do + # temporarily, remove the arg. + shift + case $arg in + -fuse-ld=bfd) + original=$ORIGINAL_LD_BFD_FOR_TARGET + ;; + -fuse-ld=gold) + original=$ORIGINAL_LD_GOLD_FOR_TARGET + ;; + -fuse-ld=lld) + original=$ORIGINAL_LLD_FOR_TARGET + # We want to remove this from the command line; by the slightly + # obtuse mechanism of not putting it back. + continue + ;; + -fuse-ld=classic) + original=$ORIGINAL_CLASSIC_LD_FOR_TARGET + # As for lld. + continue + ;; + *) ;; + esac + # if we want to keep the arg, put it back. + set -- "$@" "$arg" + done prog=ld-new$exeext if test "$original" = ../gold/ld-new$exeext; then dir=gold