[v2] jit: set JIT_LDFLAGS for MinGW [PR125229]

Message ID SL2SPRMB0007676C2BC38B944A503C94EF932@SL2SPRMB0007.KORP216.PROD.OUTLOOK.COM
State Committed
Commit 2577be489a992edfc4e5987cc2c85111f401762c
Headers
Series [v2] jit: set JIT_LDFLAGS for MinGW [PR125229] |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply

Commit Message

Zhongteng Gui Oct. 8, 2026, 5:58 p.m. UTC
  Changes since v1:

- Seperate conditions for JIT_LDFLAGS and LIBGCCJIT_EXTRA_OPTS, as suggested by Jonathan.

- Fixed a bug in v1: when host is Darwin and target is MinGW, existing special handling for
JIT_LDFLAGS on Darwin hosts will also be effective.

---

From 67555815a16ef23ba491df2451015bd1fcc20579 Mon Sep 17 00:00:00 2001
From: Zhongteng Gui <dragon-archer@outlook.com>
Date: Fri, 9 Oct 2026 01:51:20 +0800
Subject: [PATCH v2] jit: Set JIT_LDFLAGS for MinGW [PR125229]

JIT_LDFLAGS is not set in the MinGW branch, so user-supplied LDFLAGS
are ignored when linking libgccjit.  This can cause build failures
when those flags are required.

Separate the JIT_LDFLAGS conditional from the LIBGCCJIT_EXTRA_OPTS
conditional to make the platform-specific handling clearer.  Use
LDFLAGS for non-Darwin hosts and apply the existing Darwin-specific
adjustments based on the host, independently of the target.

gcc/jit/ChangeLog:

    PR jit/125229
    * Make-lang.in (JIT_LDFLAGS): Define in a separate host-based
    conditional, using LDFLAGS for non-Darwin hosts.

Signed-off-by: Zhongteng Gui <dragon-archer@outlook.com>
---
 gcc/jit/Make-lang.in | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
  

Comments

Jonathan Yong Oct. 9, 2026, 10:45 a.m. UTC | #1
On 10/8/26 17:58, Zhongteng Gui wrote:
> Changes since v1:
> 
> - Seperate conditions for JIT_LDFLAGS and LIBGCCJIT_EXTRA_OPTS, as suggested by Jonathan.
> 
> - Fixed a bug in v1: when host is Darwin and target is MinGW, existing special handling for
> JIT_LDFLAGS on Darwin hosts will also be effective.
> 
Thanks, pushed to master branch.
  

Patch

diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in
index eb1c9966062..476a82ea708 100644
--- a/gcc/jit/Make-lang.in
+++ b/gcc/jit/Make-lang.in
@@ -153,6 +153,16 @@  jit_OBJS = $(JIT_OBJS) $(JIT_TARGET_OBJS)
 # Use strict warnings for this front end.
 jit-warn = $(STRICT_WARN)
 
+ifneq (,$(findstring darwin,$(host)))
+# Use the default (shared) libgcc.
+JIT_LDFLAGS = $(filter-out -static-libgcc, $(LDFLAGS))
+ifeq (,$(findstring darwin8,$(host)))
+JIT_LDFLAGS += -Wl,-rpath,@loader_path
+endif
+else
+JIT_LDFLAGS = $(LDFLAGS)
+endif
+
 ifneq (,$(findstring mingw,$(target)))
 # Create import library
 LIBGCCJIT_EXTRA_OPTS = -Wl,--out-implib,$(LIBGCCJIT_IMPORT_LIB)
@@ -162,13 +172,7 @@  LIBGCCJIT_VERS = $(LIBGCCJIT_CURRENT).$(LIBGCCJIT_REVISION).$(LIBGCCJIT_AGE)
 LIBGCCJIT_EXTRA_OPTS = -Wl,-current_version,$(LIBGCCJIT_VERS) \
  -Wl,-compatibility_version,$(LIBGCCJIT_COMPAT) \
   $(LIBGCCJIT_VERSION_SCRIPT_OPTION) $(LIBGCCJIT_SONAME_OPTION)
-# Use the default (shared) libgcc.
-JIT_LDFLAGS = $(filter-out -static-libgcc, $(LDFLAGS))
-ifeq (,$(findstring darwin8,$(host)))
-JIT_LDFLAGS += -Wl,-rpath,@loader_path
-endif
 else
-JIT_LDFLAGS = $(LDFLAGS)
 LIBGCCJIT_EXTRA_OPTS = $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
 	$(LIBGCCJIT_SONAME_OPTION)
 endif