When linking with a static libgphobos on NetBSD/amd64, gld 2.46 warns

gld-2.46: warning: /usr/lib/crtn.o: missing .note.GNU-stack section implies 
executable stack

This is caused by libdruntime/config/common/threadasm.S including the
note on NetBSD.  This was introduced in the original druntime repo with

commit 3d8d4a45c01832fb657c16a656b6e1566d77fb21
Author: Nikolay Tolstokulakov <[email protected]>
Date:   Thu Feb 4 13:40:21 2016 +0600

    netbsd patch

apparently by simply matching what FreeBSD and NetBSD do.  However,
NetBSD doesn't use those notes: TARGET_ASM_FILE_END isn't defined and
the bundled GCC 10.5.0 doesn't emit it either.

Therefore this patch omits it.

The same issue is still present in upstream DMD in
druntime/src/core/thread/fiber/switch_context_asm.S.

Bootstapped without regressions on amd64-pc-netbsd10.1.

Ok for trunk?

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2026-07-05  Rainer Orth  <[email protected]>

        libphobos:
        * libdruntime/config/common/threadasm.S: Don't emit
        .note.GNU-stack on NetBSD.

# HG changeset patch
# Parent  99e3a14db0049b16c68a3c18e47c5e29a6931a36
libphobos: Disable .note.GNU-stack on NetBSD

diff --git a/libphobos/libdruntime/config/common/threadasm.S b/libphobos/libdruntime/config/common/threadasm.S
--- a/libphobos/libdruntime/config/common/threadasm.S
+++ b/libphobos/libdruntime/config/common/threadasm.S
@@ -22,7 +22,7 @@ a copy of the GCC Runtime Library Except
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#if (__linux__ || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__) && __ELF__
+#if (__linux__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__) && __ELF__
 /*
  * Mark the resulting object file as not requiring execution permissions on
  * stack memory. The absence of this section would mark the whole resulting

Reply via email to