Re: [PATCH v3 0/9] Improve ld.lld-21+ compatibility when building i386-pc target

2026-02-16 Thread Daniel Kiper
On Fri, Feb 13, 2026 at 08:05:00PM -0500, Nicholas Vinson wrote:
> Starting with ld.llvm-21, any attempt create a non-relocatable binary and set
> one more secton addresses below 0x40 results in a linker error. 
> Furthermore,
> the differences between ld.bfd and ld.lld made finding a proper set of
> command-line flags tht worked with both linkers and bypass the image base
> address restriction difficult. Therefore, the approach of using a custom 
> linker
> script was adopted to solve the issue.
>
> This approach was tested using:
>
> ../configure CC=clang CXX=clang++ LDFLAGS="-fuse-ld=lld" 
> TARGET_LDFLAGS="-fuse-ld=lld" --with-platform=pc
> ../configure CC=clang CXX=clang++ --with-platform=pc (both with ld.lld as the 
> default and ld.bfd as the default)
> ../configure CC=gcc CXX=g++ --with-platform=pc
>
> and a VM was used for testing. To build the disk images the VM was booted 
> with,
> the following scripts were used:

[...]

> In all cases, the VM successfully booted to the standard GRUB prompt.
>
> Nicholas Vinson (9):
>   i386/pc/int.h: conditionally apply regparm attr.
>   grub-core: Update kernel image generation
>   i386-cygwin-img-ld.sc -> i386-cygwin-img.lds
>   Revert "configure: Print a more helpful error if autoconf-archive is
> not installed"
>   Revert "configure: Check linker for --image-base support"
>   Revert "INSTALL: Add note that the GNU Autoconf Archive may be needed"
>   configure: drop -Ttext checks for i386-pc
>   configure.ac: Add --image-base check for non-i386
>   conf/i386-cygwin-img.lds: Update to use _grub_text_base symbol

Still Windows builds are broken... :-(

  ./configure --build=x86_64-linux-gnu --host=x86_64-w64-mingw32 
--target=x86_64-w64-mingw32 --with-platform=efi --enable-stack-protector
  [...]
  checking whether x86_64-w64-mingw32-objcopy works for absolute addresses... 
configure: error: x86_64-w64-mingw32-gcc cannot link at address 0x2000

The INSTALL file lists compilers packages which are needed to build GRUB
for all architectures and platforms.

Daniel

___
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH v3 0/9] Improve ld.lld-21+ compatibility when building i386-pc target

2026-02-13 Thread Nicholas Vinson
Starting with ld.llvm-21, any attempt create a non-relocatable binary and set
one more secton addresses below 0x40 results in a linker error. Furthermore,
the differences between ld.bfd and ld.lld made finding a proper set of
command-line flags tht worked with both linkers and bypass the image base
address restriction difficult. Therefore, the approach of using a custom linker
script was adopted to solve the issue.

This approach was tested using:

../configure CC=clang CXX=clang++ LDFLAGS="-fuse-ld=lld" 
TARGET_LDFLAGS="-fuse-ld=lld" --with-platform=pc
../configure CC=clang CXX=clang++ --with-platform=pc (both with ld.lld as the 
default and ld.bfd as the default)
../configure CC=gcc CXX=g++ --with-platform=pc

and a VM was used for testing. To build the disk images the VM was booted with,
the following scripts were used:

EFI disk:
--- /dev/null   2026-01-18 13:24:44.262332704 -0500
+++ efi_disk_image.sh   2026-01-25 11:17:33.554420324 -0500
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -xe
+
+dd if=/dev/zero of=grub.img bs=1M count=100 status=progress
+
+sfdisk --force --no-reread --no-tell-kernel grub.img < i386-cygwin-img.lds
  Revert "configure: Print a more helpful error if autoconf-archive is
not installed"
  Revert "configure: Check linker for --image-base support"
  Revert "INSTALL: Add note that the GNU Autoconf Archive may be needed"
  configure: drop -Ttext checks for i386-pc
  configure.ac: Add --image-base check for non-i386
  conf/i386-cygwin-img.lds: Update to use _grub_text_base symbol

 .gitignore|  3 +-
 INSTALL   |  1 -
 acinclude.m4  | 18 --
 conf/Makefile.extra-dist  |  3 +-
 ...6-cygwin-img-ld.sc => i386-cygwin-img.lds} |  1 +
 conf/i386-pc-kernel.lds   | 51 
 configure.ac  | 61 ---
 grub-core/Makefile.core.def   | 31 +-
 include/grub/i386/pc/int.h|  5 +-
 m4/ax_check_link_flag.m4  | 53 
 10 files changed, 181 insertions(+), 46 deletions(-)
 rename conf/{i386-cygwin-img-ld.sc => i386-cygwin-img.lds} (97%)
 create mode 100644 conf/i386-pc-kernel.lds
 create mode 100644 m4/ax_check_link_flag.m4

-- 
2.53.0


___
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel