|
|
2be09a |
commit 0dcbf4c8705309af8c8c1620491c60539901a3b0
|
|
|
2be09a |
Author: Joseph Myers <joseph@codesourcery.com>
|
|
|
2be09a |
Date: Fri Sep 17 13:12:10 2021 +0000
|
|
|
2be09a |
|
|
|
2be09a |
Run conform/ tests using newly built libc
|
|
|
2be09a |
|
|
|
2be09a |
Although the conform/ header tests are built using the headers of the
|
|
|
2be09a |
glibc under test, the execution tests from conformtest (a few tests of
|
|
|
2be09a |
the values of macros evaluating to string constants) are linked and
|
|
|
2be09a |
run with system libc, not the newly built libc.
|
|
|
2be09a |
|
|
|
2be09a |
Apart from preventing testing in cross environments, this can be a
|
|
|
2be09a |
problem even for native testing. Specifically, it can be useful to do
|
|
|
2be09a |
native testing when building with a cross compiler that links with a
|
|
|
2be09a |
libc that is not the system libc; for example, on x86_64, you can test
|
|
|
2be09a |
all three ABIs that way if the kernel support is present, even if the
|
|
|
2be09a |
host OS lacks 32-bit or x32 libraries or they are older than the
|
|
|
2be09a |
libraries in the sysroot used by the compiler used to build glibc.
|
|
|
2be09a |
This works for almost all tests, but not for these conformtest tests.
|
|
|
2be09a |
|
|
|
2be09a |
Arrange for conformtest to link and run test programs similarly to
|
|
|
2be09a |
other tests, with consequent refactoring of various variables in
|
|
|
2be09a |
Makeconfig to allow passing relevant parts of the link-time command
|
|
|
2be09a |
lines down to conformtest. In general, the parts of the link command
|
|
|
2be09a |
involving $@ or $^ are separated out from the parts that should be
|
|
|
2be09a |
passed to conformtest (the variables passed to conformtest still
|
|
|
2be09a |
involve various variables whose names involve $(@F), but those
|
|
|
2be09a |
variables simply won't be defined for the conformtest makefile rules
|
|
|
2be09a |
and I think their presence there is harmless).
|
|
|
2be09a |
|
|
|
2be09a |
This is also most of the support that would be needed to allow running
|
|
|
2be09a |
those tests of string constants for cross testing when test-wrapper is
|
|
|
2be09a |
defined. That will also need changes to where conformtest.py puts the
|
|
|
2be09a |
test executables, so it puts them in the main object directory
|
|
|
2be09a |
(expected to be shared with a test system in cross testing) rather
|
|
|
2be09a |
than /tmp (not expected to be shared) as at present.
|
|
|
2be09a |
|
|
|
2be09a |
Tested for x86_64.
|
|
|
2be09a |
|
|
|
2be09a |
(cherry picked from commit f3eef963902d0f54f68cffc74f79b97f4d6154b7)
|
|
|
2be09a |
|
|
|
2be09a |
diff --git a/Makeconfig b/Makeconfig
|
|
|
2be09a |
index 68663d984e6a1264..2fa0884b4eee5e53 100644
|
|
|
2be09a |
--- a/Makeconfig
|
|
|
2be09a |
+++ b/Makeconfig
|
|
|
2be09a |
@@ -412,12 +412,13 @@ link-extra-libs-tests = $(libsupport)
|
|
|
2be09a |
|
|
|
2be09a |
# Command for linking PIE programs with the C library.
|
|
|
2be09a |
ifndef +link-pie
|
|
|
2be09a |
-+link-pie-before-libc = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
|
|
|
2be09a |
- -Wl,-O1 -nostdlib -nostartfiles -o $@ \
|
|
|
2be09a |
++link-pie-before-inputs = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
|
|
|
2be09a |
+ -Wl,-O1 -nostdlib -nostartfiles \
|
|
|
2be09a |
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
|
|
|
2be09a |
$(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
|
|
|
2be09a |
$(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
|
|
|
2be09a |
- $(+preinit) $(+prectorS) \
|
|
|
2be09a |
+ $(+preinit) $(+prectorS)
|
|
|
2be09a |
++link-pie-before-libc = -o $@ $(+link-pie-before-inputs) \
|
|
|
2be09a |
$(filter-out $(addprefix $(csu-objpfx),start.o \
|
|
|
2be09a |
S$(start-installed-name))\
|
|
|
2be09a |
$(+preinit) $(link-extra-libs) \
|
|
|
2be09a |
@@ -442,11 +443,12 @@ endef
|
|
|
2be09a |
endif
|
|
|
2be09a |
# Command for statically linking programs with the C library.
|
|
|
2be09a |
ifndef +link-static
|
|
|
2be09a |
-+link-static-before-libc = -nostdlib -nostartfiles -static -o $@ \
|
|
|
2be09a |
++link-static-before-inputs = -nostdlib -nostartfiles -static \
|
|
|
2be09a |
$(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)) \
|
|
|
2be09a |
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
|
|
|
2be09a |
$(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
|
|
|
2be09a |
- $(+preinit) $(+prectorT) \
|
|
|
2be09a |
+ $(+preinit) $(+prectorT)
|
|
|
2be09a |
++link-static-before-libc = -o $@ $(+link-static-before-inputs) \
|
|
|
2be09a |
$(filter-out $(addprefix $(csu-objpfx),start.o \
|
|
|
2be09a |
$(start-installed-name))\
|
|
|
2be09a |
$(+preinit) $(link-extra-libs-static) \
|
|
|
2be09a |
@@ -473,13 +475,16 @@ endif
|
|
|
2be09a |
ifeq (yes,$(build-pie-default))
|
|
|
2be09a |
+link = $(+link-pie)
|
|
|
2be09a |
+link-tests = $(+link-pie-tests)
|
|
|
2be09a |
++link-tests-before-inputs = $(+link-pie-before-inputs) $(rtld-tests-LDFLAGS)
|
|
|
2be09a |
++link-tests-after-inputs = $(link-libc-tests) $(+link-pie-after-libc)
|
|
|
2be09a |
+link-printers-tests = $(+link-pie-printers-tests)
|
|
|
2be09a |
else # not build-pie-default
|
|
|
2be09a |
-+link-before-libc = -nostdlib -nostartfiles -o $@ \
|
|
|
2be09a |
++link-before-inputs = -nostdlib -nostartfiles \
|
|
|
2be09a |
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
|
|
|
2be09a |
$(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
|
|
|
2be09a |
$(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
|
|
|
2be09a |
- $(+preinit) $(+prector) \
|
|
|
2be09a |
+ $(+preinit) $(+prector)
|
|
|
2be09a |
++link-before-libc = -o $@ $(+link-before-inputs) \
|
|
|
2be09a |
$(filter-out $(addprefix $(csu-objpfx),start.o \
|
|
|
2be09a |
$(start-installed-name))\
|
|
|
2be09a |
$(+preinit) $(link-extra-libs) \
|
|
|
2be09a |
@@ -491,6 +496,8 @@ $(CC) $(link-libc-rpath-link) $(+link-before-libc) $(rtld-LDFLAGS) \
|
|
|
2be09a |
$(link-extra-flags) $(link-libc) $(+link-after-libc)
|
|
|
2be09a |
$(call after-link,$@)
|
|
|
2be09a |
endef
|
|
|
2be09a |
++link-tests-before-inputs = $(+link-before-inputs) $(rtld-tests-LDFLAGS)
|
|
|
2be09a |
++link-tests-after-inputs = $(link-libc-tests) $(+link-after-libc)
|
|
|
2be09a |
define +link-tests
|
|
|
2be09a |
$(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
|
|
|
2be09a |
$(+link-after-libc)
|
|
|
2be09a |
@@ -505,6 +512,8 @@ endif # build-pie-default
|
|
|
2be09a |
else # build-static
|
|
|
2be09a |
+link = $(+link-static)
|
|
|
2be09a |
+link-tests = $(+link-static-tests)
|
|
|
2be09a |
++link-tests-before-inputs = $(+link-static-before-inputs)
|
|
|
2be09a |
++link-tests-after-inputs = $(link-libc-static-tests) $(+link-static-after-libc)
|
|
|
2be09a |
+link-printers-tests = $(+link-static-tests)
|
|
|
2be09a |
endif # build-shared
|
|
|
2be09a |
endif # +link
|
|
|
2be09a |
diff --git a/conform/Makefile b/conform/Makefile
|
|
|
2be09a |
index c64a83a905b991cc..296db818f0a72253 100644
|
|
|
2be09a |
--- a/conform/Makefile
|
|
|
2be09a |
+++ b/conform/Makefile
|
|
|
2be09a |
@@ -176,6 +176,9 @@ $(conformtest-header-tests): $(objpfx)%/conform.out: \
|
|
|
2be09a |
(set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
|
|
|
2be09a |
mkdir -p $(@D); \
|
|
|
2be09a |
$(PYTHON) $< --cc='$(CC)' --flags='$(conformtest-cc-flags)' \
|
|
|
2be09a |
+ --ldflags='$(+link-tests-before-inputs)' \
|
|
|
2be09a |
+ --libs='$(+link-tests-after-inputs)' \
|
|
|
2be09a |
+ --run-program-prefix='$(run-program-prefix)' \
|
|
|
2be09a |
--standard=$$std --header=$$hdr $(conformtest-xfail) \
|
|
|
2be09a |
$(conformtest-cross) \
|
|
|
2be09a |
> $@ 2>&1;; \
|
|
|
2be09a |
diff --git a/conform/conformtest.py b/conform/conformtest.py
|
|
|
2be09a |
index f0405b71869831f9..4898e16c9fb96503 100644
|
|
|
2be09a |
--- a/conform/conformtest.py
|
|
|
2be09a |
+++ b/conform/conformtest.py
|
|
|
2be09a |
@@ -381,12 +381,16 @@ class MacroStrTest(object):
|
|
|
2be09a |
class HeaderTests(object):
|
|
|
2be09a |
"""The set of tests run for a header."""
|
|
|
2be09a |
|
|
|
2be09a |
- def __init__(self, header, standard, cc, flags, cross, xfail):
|
|
|
2be09a |
+ def __init__(self, header, standard, cc, flags, ldflags, libs,
|
|
|
2be09a |
+ run_program_prefix, cross, xfail):
|
|
|
2be09a |
"""Initialize a HeaderTests object."""
|
|
|
2be09a |
self.header = header
|
|
|
2be09a |
self.standard = standard
|
|
|
2be09a |
self.cc = cc
|
|
|
2be09a |
self.flags = flags
|
|
|
2be09a |
+ self.ldflags = ldflags
|
|
|
2be09a |
+ self.libs = libs
|
|
|
2be09a |
+ self.run_program_prefix = run_program_prefix
|
|
|
2be09a |
self.cross = cross
|
|
|
2be09a |
self.xfail_str = xfail
|
|
|
2be09a |
self.cflags_namespace = ('%s -fno-builtin %s -D_ISOMAC'
|
|
|
2be09a |
@@ -590,7 +594,8 @@ class HeaderTests(object):
|
|
|
2be09a |
exe_file = os.path.join(self.temp_dir, 'test')
|
|
|
2be09a |
with open(c_file, 'w') as c_file_out:
|
|
|
2be09a |
c_file_out.write('#include <%s>\n%s' % (self.header, text))
|
|
|
2be09a |
- cmd = ('%s %s %s -o %s' % (self.cc, self.cflags, c_file, exe_file))
|
|
|
2be09a |
+ cmd = ('%s %s %s %s %s -o %s' % (self.cc, self.cflags, self.ldflags,
|
|
|
2be09a |
+ c_file, self.libs, exe_file))
|
|
|
2be09a |
try:
|
|
|
2be09a |
subprocess.check_call(cmd, shell=True)
|
|
|
2be09a |
except subprocess.CalledProcessError:
|
|
|
2be09a |
@@ -600,7 +605,9 @@ class HeaderTests(object):
|
|
|
2be09a |
self.note_skip(name)
|
|
|
2be09a |
return
|
|
|
2be09a |
try:
|
|
|
2be09a |
- subprocess.check_call(exe_file, shell=True)
|
|
|
2be09a |
+ subprocess.check_call('%s %s' % (self.run_program_prefix,
|
|
|
2be09a |
+ exe_file),
|
|
|
2be09a |
+ shell=True)
|
|
|
2be09a |
except subprocess.CalledProcessError:
|
|
|
2be09a |
self.note_error(name, self.group_xfail)
|
|
|
2be09a |
return
|
|
|
2be09a |
@@ -719,12 +726,19 @@ def main():
|
|
|
2be09a |
help='C compiler to use')
|
|
|
2be09a |
parser.add_argument('--flags', metavar='CFLAGS',
|
|
|
2be09a |
help='Compiler flags to use with CC')
|
|
|
2be09a |
+ parser.add_argument('--ldflags', metavar='LDFLAGS',
|
|
|
2be09a |
+ help='Compiler arguments for linking before inputs')
|
|
|
2be09a |
+ parser.add_argument('--libs', metavar='LIBS',
|
|
|
2be09a |
+ help='Compiler arguments for linking after inputs')
|
|
|
2be09a |
+ parser.add_argument('--run-program-prefix', metavar='RUN-PROGRAM-PREFIX',
|
|
|
2be09a |
+ help='Wrapper for running newly built program')
|
|
|
2be09a |
parser.add_argument('--cross', action='store_true',
|
|
|
2be09a |
help='Do not run compiled test programs')
|
|
|
2be09a |
parser.add_argument('--xfail', metavar='COND',
|
|
|
2be09a |
help='Name of condition for XFAILs')
|
|
|
2be09a |
args = parser.parse_args()
|
|
|
2be09a |
tests = HeaderTests(args.header, args.standard, args.cc, args.flags,
|
|
|
2be09a |
+ args.ldflags, args.libs, args.run_program_prefix,
|
|
|
2be09a |
args.cross, args.xfail)
|
|
|
2be09a |
tests.run()
|
|
|
2be09a |
|