Repository: SCons/scons (language: python)

Issue:
as-live test fails on new GNU assembler
On a recently updated debian 12 "bookworm" (this is current "testing" version, not "stable"), the live assembler test fails due to warnings being emitted, and not expected by the test.  Looks like this:
```console
1/1 (100.00%) /usr/bin/python test/AS/as-live.py
STDOUT =========================================================================
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
as -o aaa.o aaa.s
gcc -o aaa_main.o -c aaa_main.c
gcc -o aaa aaa.o aaa_main.o
/usr/bin/python wrapper.py /usr/bin/as -o bbb.o bbb.s
gcc -o bbb_main.o -c bbb_main.c
gcc -o bbb bbb.o bbb_main.o
gcc -I. -c -o ccc.o ccc.S
gcc -o ccc_main.o -c -I. ccc_main.c
gcc -o ccc ccc.o ccc_main.o
scons: done building targets.

STDERR =========================================================================
0a1,6
> /bin/ld: warning: aaa.o: missing .note.GNU-stack section implies executable stack
> /bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
> /bin/ld: warning: bbb.o: missing .note.GNU-stack section implies executable stack
> /bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
> /bin/ld: warning: ccc.o: missing .note.GNU-stack section implies executable stack
> /bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

FAILED test of /home/mats/github/scons/scripts/scons.py
        at line 665 of /home/mats/github/scons/testing/framework/TestCommon.py (_complete)
        from line 754 of /home/mats/github/scons/testing/framework/TestCommon.py (run)
        from line 464 of /home/mats/github/scons/testing/framework/TestSCons.py (run)
        from line 167 of /home/mats/github/scons/test/AS/as-live.py
```
This assembler identifies itself as:
```console
GNU assembler (GNU Binutils for Debian) 2.38.90.20220713
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-linux-gnu'.
```


Discussion / hints:
This is some decent reading on the topic, though of course it has a Gentoo flavor:

https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart


It seems the section info stuff only works on a `.S` (uppercase) assembler source file which will be preprocessed, not on a `.s` (lowercase). The test generates two lcase-s files and one ucase-S file, thus the triple complaint above.

Fix patch:
diff --git a/CHANGES.txt b/CHANGES.txt
index a55c532496..b2e7182dfa 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -179,6 +179,8 @@ RELEASE  VERSION/DATE TO BE FILLED IN LATER
       Python stdlib types module.
     - TeX tests: skip tests that use makeindex or epstopdf not installed, or
       if `kpsewhich glossaries.sty` fails.
+    - Added a .note.GNU-stack section to the test assembler files to
+      avoid the GNU linker issuing warnings for its absence.
 
 
   From Jonathon Reinhart:


Test patch:
diff --git a/test/AS/as-live.py b/test/AS/as-live.py
index 676b5375ee..4a21fcf6f0 100644
--- a/test/AS/as-live.py
+++ b/test/AS/as-live.py
@@ -1,6 +1,8 @@
 #!/usr/bin/env python
 #
-# __COPYRIGHT__
+# MIT License
+#
+# Copyright The SCons Foundation
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -20,9 +22,6 @@
 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 """
 Verify correct use of the live 'as' assembler.
@@ -37,24 +36,22 @@
 
 test = TestSCons.TestSCons()
 
-
-
 if not test.detect('AS', 'as'):
     test.skip_test("as not found; skipping test\n")
 
 x86 = (sys.platform == 'win32' or sys.platform.find('linux') != -1)
-
 if not x86:
     test.skip_test("skipping as test on non-x86 platform '%s'\n" % sys.platform)
 
 namelbl = "name"
-testccc = """ccc = aaa.Clone(CPPPATH=['.'])
-ccc.Program(target = 'ccc', source = ['ccc.S', 'ccc_main.c'])
+testccc = """\
+ccc = aaa.Clone(CPPPATH=['.'])
+ccc.Program(target='ccc', source=['ccc.S', 'ccc_main.c'])
 """
 if sys.platform == "win32":
     namelbl = "_name"
     testccc = ""
-    
+
 test.write("wrapper.py", """\
 import subprocess
 import sys
@@ -66,30 +63,34 @@
 
 test.write('SConstruct', """\
 aaa = Environment()
-aaa.Program(target = 'aaa', source = ['aaa.s', 'aaa_main.c'])
-bbb = aaa.Clone(AS = r'%(_python_)s wrapper.py ' + WhereIs('as'))
-bbb.Program(target = 'bbb', source = ['bbb.s', 'bbb_main.c'])
+aaa.Program(target='aaa', source=['aaa.s', 'aaa_main.c'])
+bbb = aaa.Clone(AS=r'%(_python_)s wrapper.py ' + WhereIs('as'))
+bbb.Program(target='bbb', source=['bbb.s', 'bbb_main.c'])
 %(testccc)s
 """ % locals())
 
-test.write('aaa.s', 
-"""        .file   "aaa.s"
-.data
-.align 4
-.globl %(namelbl)s
+test.write('aaa.s', """
+    .file   "aaa.s"
+    .data
+    .align 4
+    .globl %(namelbl)s
 %(namelbl)s:
-        .ascii	"aaa.s"
-        .byte	0
+    .ascii	"aaa.s"
+    .byte	0
+    .ident  "handcrafted test assembly"
+    .section    .note.GNU-stack,"",@progbits
 """ % locals())
 
 test.write('bbb.s', """\
-.file   "bbb.s"
-.data
-.align 4
-.globl %(namelbl)s
+    .file   "bbb.s"
+    .data
+    .align 4
+    .globl %(namelbl)s
 %(namelbl)s:
-        .ascii	"bbb.s"
-        .byte	0
+    .ascii	"bbb.s"
+    .byte	0
+    .ident  "handcrafted test assembly"
+    .section    .note.GNU-stack,"",@progbits
 """ % locals())
 
 test.write('ccc.h', """\
@@ -98,13 +99,15 @@
 
 test.write('ccc.S', """\
 #include <ccc.h>
-.file   STRING
-.data
-.align 4
-.globl name
+    .file   STRING
+    .data
+    .align 4
+    .globl name
 name:
-        .ascii	STRING
-        .byte	0
+    .ascii	STRING
+    .byte	0
+    .ident  "handcrafted test assembly"
+    .section    .note.GNU-stack,"",@progbits
 """)
 
 test.write('aaa_main.c', r"""
@@ -171,13 +174,13 @@
 
 if sys.platform != "win32":
     test.run(program = test.workpath('ccc'), stdout =  "ccc_main.c ccc.S\n")
-    
+
     test.must_match('wrapper.out', "wrapper.py: bbb.s\n")
-    
+
     test.write("ccc.h", """\
     #define STRING  "ccc.S 2"
     """)
-    
+
     test.run()
     test.run(program = test.workpath('ccc'), stdout =  "ccc_main.c ccc.S 2\n")