This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gold testsuite: conditionalize -fmerge-constants use, clean up test


Clang does not grok the -fmerge-constants switch, but it always emits
strings in SHF_MERGE sections anyway.  So I conditionalized the use of
the flag but did not conditionalize the tests that rely on the behavior.
The test files generate -Wmissing-prototypes warnings as C; we elide that
warning option for C++, and the code looks like it was intended as C++
rather than C anyway (using () rather than (void) in prototypes), so the
renaming was the simplest way to avoid the warnings.

Note that the patch omits changes to generated files, and also omits the
file-renaming diff (included in git format, but no actual diffs).

OK for trunk and 2.24?


Thanks,
Roland


gold/
	* configure.ac (MERGE_CONSTANTS_CFLAGS): New check.
    	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* testsuite/merge_string_literals_1.c: Renamed to have .cc suffix.
	* testsuite/merge_string_literals_2.c: Likewise.
	* testsuite/Makefile.am
	(merge_string_literals_1.o, merge_string_literals_2.o): Update deps.
	(AM_CFLAGS, AM_CXXFLAGS): Use $(MERGE_CONSTANTS_FLAGS) in place of
	literal -fmerge-constants.
	* testsuite/Makefile.in: Regenerate.

--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -338,6 +338,19 @@ dnl Whether we can test -mcmodel=medium.
 AM_CONDITIONAL(MCMODEL_MEDIUM,
 [test "$target_cpu" = "x86_64" -a "$have_mcmodel_medium" = "yes" -a
"$gold_cv_prog_gcc41" = "yes"])

+AC_CACHE_CHECK([whether $CC supports -fmerge-constants],
+	       [gold_cv_merge_constants], [
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -fmerge-constants"
+AC_COMPILE_IFELSE([const char *s = "foo";],
+		  [have_merge_constants=yes],
+		  [have_merge_constants=no])
+CFLAGS="$save_CFLAGS"])
+AC_SUBST([MERGE_CONSTANTS_CFLAGS])
+AS_IF([test "$gold_cv_merge_constants" = yes],
+      [MERGE_CONSTANTS_CFLAGS=-fmerge-constants],
+      [MERGE_CONSTANTS_CFLAGS=])
+
 dnl Test for __thread support.
 AC_CACHE_CHECK([for thread support], [gold_cv_c_thread],
 [AC_COMPILE_IFELSE([__thread int i = 1;],
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -8,10 +8,10 @@
 AUTOMAKE_OPTIONS = foreign -Wno-portability

 # The two_file_test tests -fmerge-constants, so we simply always turn
-# it on.  This may need to be controlled by a configure option
-# eventually.
-AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -fmerge-constants
-AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) -fmerge-constants
+# it on.  For compilers that do not support the command-line option,
+# we assume they just always emit SHF_MERGE sections unconditionally.
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(MERGE_CONSTANTS_FLAGS)
+AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(MERGE_CONSTANTS_FLAGS)

 AM_CPPFLAGS = \
 	-I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \
@@ -337,9 +337,9 @@ large_symbol_alignment_LDADD =
 check_SCRIPTS += merge_string_literals.sh
 check_DATA += merge_string_literals.stdout
 MOSTLYCLEANFILES += merge_string_literals
-merge_string_literals_1.o: merge_string_literals_1.c
+merge_string_literals_1.o: merge_string_literals_1.cc
 	$(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $<
-merge_string_literals_2.o: merge_string_literals_2.c
+merge_string_literals_2.o: merge_string_literals_2.cc
 	$(CXXCOMPILE) -O2 -c -fPIC -g -o $@ $<
 merge_string_literals: merge_string_literals_1.o
merge_string_literals_2.o gcctestdir/ld
 	$(CXXLINK) -Bgcctestdir/ merge_string_literals_1.o
merge_string_literals_2.o -O2 -shared -nostdlib
diff --git a/gold/testsuite/merge_string_literals_1.c
b/gold/testsuite/merge_string_literals_1.cc
similarity index 100%
rename from gold/testsuite/merge_string_literals_1.c
rename to gold/testsuite/merge_string_literals_1.cc
diff --git a/gold/testsuite/merge_string_literals_2.c
b/gold/testsuite/merge_string_literals_2.cc
similarity index 100%
rename from gold/testsuite/merge_string_literals_2.c
rename to gold/testsuite/merge_string_literals_2.cc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]