Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nHZyA-0007jP-G6 for mharc-grub-devel@gnu.org; Tue, 08 Feb 2022 18:32:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <37fsCYgcKCggui0szi6owwotm.kwuoz2j-lm3mtov2.wzo@flex--maskray.bounces.google.com>) id 1nHZy9-0007jD-7Y for grub-devel@gnu.org; Tue, 08 Feb 2022 18:32:21 -0500 Received: from [2607:f8b0:4864:20::b49] (port=34773 helo=mail-yb1-xb49.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <37fsCYgcKCggui0szi6owwotm.kwuoz2j-lm3mtov2.wzo@flex--maskray.bounces.google.com>) id 1nHZy7-0006x5-2C for grub-devel@gnu.org; Tue, 08 Feb 2022 18:32:20 -0500 Received: by mail-yb1-xb49.google.com with SMTP id s73-20020a25aa4f000000b0061d764d3c13so1135477ybi.1 for ; Tue, 08 Feb 2022 15:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=k5e05os4HviCe04ckEoBPLCa25TOvrCwkc3kl0SRl/Q=; b=Q1OpiAjpTsz00jM3QBSujvR9kKp1W3uC3Y5BLu+4W9cCdTfJBne6Q/Ye62RtsGKAcI WVY2BHrCuOS6OxdrLvcTlXwSIVLbYcIQroYZ1gP694pLPMjut8kzMqKm0YSpQpvQfOHd mP3RFeUgTjDkrPnmx1GjY2MN2KUGnrgjOtRHkEokOOhbU1T5ttVc1Whhp20EfrKQ4aN8 k8e3pPkUzzgBJt6LvgF8/kSJaKdO/K3Gmm3YTp/yfO8fY7ATx2vyY9WxsH0UJf1uBQdb n4g7m4fj/IN/c5be+McDY/4HncLC6rcOrYP8gxxVPglxNzDnkHvWm4S40FZDPPGXoSdO EB/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=k5e05os4HviCe04ckEoBPLCa25TOvrCwkc3kl0SRl/Q=; b=fKPceJfl3BjI6028wuVgxiOp5Rfm0GIz+zkHb7chf/fa18sZ0EnuP035ijj58XCGty gJOYTAMkc7R6oYfuQlKt9YbQClebgODw7/+t7PRY7ZSC0ghm0Rnb0voOmnJMtFvC+h/b WDSwVsPeBmCCqLDzPyfGb5kA0k9rDaMk9Nrh4MKJRbS0wL/ZsOf8MKGKPVzUKYsgNtyq iL05s3Oh8mRtLrrcViQ/l2d+ZvvXz3W7zyubwiBw+KAMgBBfQA8xFfzQ3em/o3OwbMbU FwaZRq8IhtByPKGc/4QVZPJ+G2UpPGspWXmANVD5Zox1hou8mezeJKEb0QNd2SUExj68 Fe1g== X-Gm-Message-State: AOAM5303YvyYbsL4BEs6s1KZlVMs7LpSRjgg6WcAtbwXpwAP2ghdrZO5 osbNp8l1V03t55ETkMP8Bir7GxnBim9cOnV35YC0/FrHE6OLOZ8J48Axw2I3oY5U/BQxL3z7rhJ HN5xN6r15GzH9yDiGhxjzP5v/fPNRR8caEKFXTc/05bfY0x1X+RbMfGIVA3Q= X-Google-Smtp-Source: ABdhPJz/BqLPSbvmpbq8HzzC94flwLS1/VfNlfT87/An0Lbp+I+OB7mnaeqjG65SleZYduIY+pfaWQOf4rTC X-Received: from maskray1.svl.corp.google.com ([2620:15c:2ce:200:6088:c379:33c0:6ed8]) (user=maskray job=sendgmr) by 2002:a25:1f82:: with SMTP id f124mr6882371ybf.545.1644362733011; Tue, 08 Feb 2022 15:25:33 -0800 (PST) Date: Tue, 8 Feb 2022 15:25:27 -0800 Message-Id: <20220208232527.2660589-1-maskray@google.com> Mime-Version: 1.0 Subject: [PATCH] configure: Replace -Wl,-r,-d with -Wl,-r From: Fangrui Song To: grub-devel@gnu.org Cc: Fangrui Song Content-Type: text/plain; charset="UTF-8" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::b49 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::b49; envelope-from=37fsCYgcKCggui0szi6owwotm.kwuoz2j-lm3mtov2.wzo@flex--maskray.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -87 X-Spam_score: -8.8 X-Spam_bar: -------- X-Spam_report: (-8.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Feb 2022 23:32:21 -0000 In GNU ld and ld.lld, -d is used with -r to allocate space to COMMON symbols. This behavior is presumably to work around legacy projects which inspect relocatable output by themselves and do not handle COMMON symbols. grub does not do this. See https://github.com/llvm/llvm-project/issues/53660 -d is quite useless and ld.lld may remove -d or make it a no-op for the 15.0.0 release. --- acinclude.m4 | 2 +- conf/Makefile.common | 2 +- grub-core/Makefile.core.def | 20 ++++++++++---------- grub-core/genmod.sh.in | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 6e14bb553..fa7840f09 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -430,7 +430,7 @@ link_nopie_needed=no] AC_MSG_CHECKING([whether linker needs disabling of PIE to work]) AC_LANG_CONFTEST([AC_LANG_SOURCE([[]])]) -[if eval "$ac_compile -Wl,-r,-d -nostdlib -Werror -o conftest.o" 2> /dev/null; then] +[if eval "$ac_compile -Wl,-r -nostdlib -Werror -o conftest.o" 2> /dev/null; then] AC_MSG_RESULT([no]) [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? rm -f conftest.o diff --git a/conf/Makefile.common b/conf/Makefile.common index f0bb6e160..1d7b39599 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -41,7 +41,7 @@ CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 8022e1c0a..ac00cc8a2 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -49,26 +49,26 @@ kernel = { nostrip = emu; - emu_ldflags = '-Wl,-r,-d'; - i386_efi_ldflags = '-Wl,-r,-d'; + emu_ldflags = '-Wl,-r'; + i386_efi_ldflags = '-Wl,-r'; i386_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; - x86_64_efi_ldflags = '-Wl,-r,-d'; + x86_64_efi_ldflags = '-Wl,-r'; x86_64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; ia64_efi_cflags = '-fno-builtin -fpic -minline-int-divide-max-throughput'; - ia64_efi_ldflags = '-Wl,-r,-d'; + ia64_efi_ldflags = '-Wl,-r'; ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; - arm_efi_ldflags = '-Wl,-r,-d'; + arm_efi_ldflags = '-Wl,-r'; arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; - arm64_efi_ldflags = '-Wl,-r,-d'; + arm64_efi_ldflags = '-Wl,-r'; arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame'; - riscv32_efi_ldflags = '-Wl,-r,-d'; + riscv32_efi_ldflags = '-Wl,-r'; riscv32_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame'; - riscv64_efi_ldflags = '-Wl,-r,-d'; + riscv64_efi_ldflags = '-Wl,-r'; riscv64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame'; i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)'; @@ -98,9 +98,9 @@ kernel = { i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; emu_cflags = '$(CFLAGS_GNULIB)'; emu_cppflags = '$(CPPFLAGS_GNULIB)'; - arm_uboot_ldflags = '-Wl,-r,-d'; + arm_uboot_ldflags = '-Wl,-r'; arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; - arm_coreboot_ldflags = '-Wl,-r,-d'; + arm_coreboot_ldflags = '-Wl,-r'; arm_coreboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; i386_pc_startup = kern/i386/pc/startup.S; diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 1250589b3..e57c4d920 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -83,9 +83,9 @@ else for dep in $deps; do echo "char moddep_$dep[] __attribute__ ((section(\"_moddeps, _moddeps\"))) = \"$dep\";" >>$t2; done if test -n "$deps"; then - @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $t2 $tmpfile -Wl,-r,-d + @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $t2 $tmpfile -Wl,-r else - @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $tmpfile -Wl,-r,-d + @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $tmpfile -Wl,-r fi rm -f $t1 $t2 $tmpfile mv $tmpfile2 $tmpfile -- 2.35.0.263.gb82422642f-goog