changeset 25596:1ac626b08c2e

12229 fix ctf test check-qualifiers for clang 12230 clang optimizer defeats ctf test suite 12231 ctf tests should not pass -h directly to clang 12232 fix clang compiler warnings in the ctf test suite 13348 ctftest should skip known failures with clang 13350 some ctf tests still rely on default compiler arch 13349 ctf tests should specify -fcommon when needed Reviewed by: Andy Fiddaman <andy@omnios.org> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Richard Lowe <richlowe@richlowe.net>
author Robert Mustacchi <rm@fingolfin.org>
date Sat, 11 Jan 2020 11:00:06 +0000
parents a013b6c81317
children d78277ff2942 2382a653be35
files usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com usr/src/test/util-tests/tests/ctf/check-common.c usr/src/test/util-tests/tests/ctf/check-common.h usr/src/test/util-tests/tests/ctf/check-qualifiers.c usr/src/test/util-tests/tests/ctf/check-sou.c usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh usr/src/test/util-tests/tests/ctf/ctftest.ksh usr/src/test/util-tests/tests/ctf/test-function.c usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c usr/src/test/util-tests/tests/ctf/test-sou.c
diffstat 17 files changed, 239 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com	Sat Jan 11 11:00:06 2020 +0000
@@ -56,33 +56,33 @@
 build: $(BINS)
 
 $(BUILDDIR)/%.32.c.o: %.c
-	$(CC) $(CFLAGS32) $(DEBUGFLAGS) -o $@ -c $<
+	$(CC) $(CFLAGS32) $(TEST_CFLAGS32) $(DEBUGFLAGS) -o $@ -c $<
 
 $(BUILDDIR)/%.64.c.o: %.c
-	$(CC) $(CFLAGS64) $(DEBUGFLAGS) -o $@ -c $<
+	$(CC) $(CFLAGS64) $(TEST_CFLAGS64) $(DEBUGFLAGS) -o $@ -c $<
 
 $(BUILDDIR)/%.32.m.o: %.c
-	$(CC) $(CFLAGS32) $(DEBUGFLAGS) -o $@ -c $<
+	$(CC) $(CFLAGS32) $(TEST_CFLAGS32) $(DEBUGFLAGS) -o $@ -c $<
 	$(CTFCONVERT) $@
 
 $(BUILDDIR)/%.64.m.o: %.c
-	$(CC) $(CFLAGS64) $(DEBUGFLAGS) -o $@ -c $<
+	$(CC) $(CFLAGS64) $(TEST_CFLAGS64) $(DEBUGFLAGS) -o $@ -c $<
 	$(CTFCONVERT) $@
 
 $(CONV32): $(OBJS_C_32)
-	$(CC) $(CFLAGS32) $(DEBUGFLAGS) -o $@ $(OBJS_C_32)
+	$(CC) $(CFLAGS32) $(TEST_CFLAGS32) $(DEBUGFLAGS) -o $@ $(OBJS_C_32)
 	$(CTFCONVERT) $@
 
 $(CONV64): $(OBJS_C_64)
-	$(CC) $(CFLAGS64) $(DEBUGFLAGS) -o $@ $(OBJS_C_64)
+	$(CC) $(CFLAGS64) $(TEST_CFLAGS64) $(DEBUGFLAGS) -o $@ $(OBJS_C_64)
 	$(CTFCONVERT) $@
 
 $(MERGE32): $(OBJS_M_32)
-	$(CC) $(CFLAGS32) $(DEBUGFLAGS) -o $@ $(OBJS_M_32)
+	$(CC) $(CFLAGS32) $(TEST_CFLAGS32) $(DEBUGFLAGS) -o $@ $(OBJS_M_32)
 	$(CTFMERGE) -t -o $@ $(OBJS_M_32)
 
 $(MERGE64): $(OBJS_M_64)
-	$(CC) $(CFLAGS64) $(DEBUGFLAGS) -o $@ $(OBJS_M_64)
+	$(CC) $(CFLAGS64) $(TEST_CFLAGS64) $(DEBUGFLAGS) -o $@ $(OBJS_M_64)
 	$(CTFMERGE) -t -o $@ $(OBJS_M_64)
 
 run-test:
--- a/usr/src/test/util-tests/tests/ctf/check-common.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/check-common.c	Sat Jan 11 11:00:06 2020 +0000
@@ -142,6 +142,12 @@
 		ctf_id_t id;
 		ctf_encoding_t enc;
 
+		if (ctftest_skip(tests[i].cn_skips)) {
+			warnx("skipping check numbers test %s due to known "
+			    "compiler issue", tests[i].cn_tname);
+			continue;
+		}
+
 		id = ctftest_lookup_type(fp, tests[i].cn_tname);
 		if (id == CTF_ERR) {
 			warnx("failed to look up %s", tests[i].cn_tname);
@@ -842,3 +848,23 @@
 
 	return (d.ctd_ret);
 }
+
+boolean_t
+ctftest_skip(check_skip_t skip)
+{
+	const char *compiler;
+
+	if (skip == 0) {
+		return (B_FALSE);
+	}
+
+	compiler = getenv("ctf_cc_type");
+	if (compiler == NULL) {
+		return (B_FALSE);
+	}
+
+	if ((skip & SKIP_CLANG) != 0 && strcmp(compiler, "clang") == 0)
+		return (B_TRUE);
+
+	return (B_FALSE);
+}
--- a/usr/src/test/util-tests/tests/ctf/check-common.h	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/check-common.h	Sat Jan 11 11:00:06 2020 +0000
@@ -31,12 +31,23 @@
 extern "C" {
 #endif
 
+/*
+ * A set of bits that can be set on tests to indicate that the test should be
+ * skipped when dealing with a certain compiler. These should be added as
+ * needed. Right now this is here because of the clang bitfield bug that is
+ * triggered by check-sou.c.
+ */
+typedef enum {
+	SKIP_CLANG	= 1 << 0
+} check_skip_t;
+
 typedef struct check_number {
 	const char *cn_tname;
 	uint_t cn_kind;
 	uint_t cn_flags;
 	uint_t cn_offset;
 	uint_t cn_size;
+	check_skip_t cn_skips;
 } check_number_t;
 
 typedef struct check_symbol {
@@ -77,6 +88,7 @@
 	int cmt_kind;
 	size_t cmt_size;
 	const check_member_t *cmt_members;
+	check_skip_t cmt_skips;
 } check_member_test_t;
 
 typedef struct check_function_test {
@@ -144,6 +156,11 @@
  */
 extern boolean_t ctftest_duplicates(ctf_file_t *);
 
+/*
+ * Determine whether or not we should skip a given test.
+ */
+extern boolean_t ctftest_skip(check_skip_t);
+
 #ifdef __cplusplus
 }
 #endif
--- a/usr/src/test/util-tests/tests/ctf/check-qualifiers.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/check-qualifiers.c	Sat Jan 11 11:00:06 2020 +0000
@@ -120,9 +120,18 @@
 	{ NULL }
 };
 
+static check_descent_t check_descent_cv_int_array_clang9[] = {
+	{ "const volatile int [13]", CTF_K_ARRAY, "const volatile int", 13 },
+	{ "const volatile int", CTF_K_CONST },
+	{ "volatile int", CTF_K_VOLATILE },
+	{ "int", CTF_K_INTEGER },
+	{ NULL }
+};
+
 static check_descent_test_t alt_descents_cv_int_array[] = {
 	{ "cv_int_array", check_descent_cv_int_array_gcc4 },
 	{ "cv_int_array", check_descent_cv_int_array_gcc7 },
+	{ "cv_int_array", check_descent_cv_int_array_clang9 },
 	{ NULL }
 };
 
@@ -142,9 +151,18 @@
 	{ NULL }
 };
 
+static check_descent_t check_descent_vc_int_array_clang9[] = {
+	{ "const volatile int [15]", CTF_K_ARRAY, "const volatile int", 15 },
+	{ "const volatile int", CTF_K_CONST },
+	{ "volatile int", CTF_K_VOLATILE },
+	{ "int", CTF_K_INTEGER },
+	{ NULL }
+};
+
 static check_descent_test_t alt_descents_vc_int_array[] = {
 	{ "vc_int_array", check_descent_vc_int_array_gcc4 },
 	{ "vc_int_array", check_descent_vc_int_array_gcc7 },
+	{ "vc_int_array", check_descent_vc_int_array_clang9 },
 	{ NULL }
 };
 
@@ -164,9 +182,19 @@
 	{ NULL }
 };
 
+static check_descent_t check_descent_vc_int_array2_clang9[] = {
+	{ "const volatile int [17]", CTF_K_ARRAY, "const volatile int", 17 },
+	{ "const volatile int", CTF_K_CONST },
+	{ "volatile int", CTF_K_VOLATILE },
+	{ "int", CTF_K_INTEGER },
+	{ NULL }
+};
+
+
 static check_descent_test_t alt_descents_vc_int_array2[] = {
 	{ "vc_int_array2", check_descent_vc_int_array2_gcc4 },
 	{ "vc_int_array2", check_descent_vc_int_array2_gcc7 },
+	{ "vc_int_array2", check_descent_vc_int_array2_clang9 },
 	{ NULL }
 };
 
@@ -214,9 +242,24 @@
 	{ NULL }
 };
 
+static check_descent_t check_descent_cv_3d_array_clang9[] = {
+	{ "const volatile int [3][2][1]", CTF_K_ARRAY,
+	    "const volatile int [2][1]", 3 },
+	{ "const volatile int [2][1]", CTF_K_ARRAY,
+	    "const volatile int [1]", 2 },
+	{ "const volatile int [1]", CTF_K_ARRAY,
+	    "const volatile int", 1 },
+	{ "const volatile int", CTF_K_CONST },
+	{ "volatile int", CTF_K_VOLATILE },
+	{ "int", CTF_K_INTEGER },
+	{ NULL }
+};
+
+
 static check_descent_test_t alt_descents_cv_3d_array[] = {
 	{ "cv_3d_array", check_descent_cv_3d_array_gcc4 },
 	{ "cv_3d_array", check_descent_cv_3d_array_gcc7 },
+	{ "cv_3d_array", check_descent_cv_3d_array_clang9 },
 	{ NULL }
 };
 
--- a/usr/src/test/util-tests/tests/ctf/check-sou.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/check-sou.c	Sat Jan 11 11:00:06 2020 +0000
@@ -41,7 +41,11 @@
 #endif
 	{ "unsigned short:1", CTF_K_INTEGER, 0, 0, 1 },
 	{ "unsigned int:7", CTF_K_INTEGER, 0, 0, 7 },
-	{ "unsigned int:32", CTF_K_INTEGER, 0, 0, 32 },
+	/*
+	 * Skipped on clang as it doesn't process csts correctly. See
+	 * check_members_csts.
+	 */
+	{ "unsigned int:32", CTF_K_INTEGER, 0, 0, 32, SKIP_CLANG },
 	{ "int:3", CTF_K_INTEGER, CTF_INT_SIGNED, 0, 3 },
 	{ NULL }
 };
@@ -233,6 +237,10 @@
 	{ NULL }
 };
 
+/*
+ * Unfortunately this test case fails with clang in at least versions 8-10. See
+ * https://bugs.llvm.org/show_bug.cgi?id=44601 for more information on the bug.
+ */
 static check_member_t check_member_csts[] = {
 	{ "rdy", "unsigned int:7", 0 },
 	{ "csts", "unsigned int:32", 7 },
@@ -317,7 +325,7 @@
 	{ "struct stats", CTF_K_STRUCT, 16, check_member_stats },
 	{ "struct fellowship", CTF_K_STRUCT, 2, check_member_fellowship },
 	{ "struct rings", CTF_K_STRUCT, 8, check_member_rings },
-	{ "struct csts", CTF_K_STRUCT, 5, check_member_csts },
+	{ "struct csts", CTF_K_STRUCT, 5, check_member_csts, SKIP_CLANG },
 	{ "union jrpg", CTF_K_UNION, 32, check_member_jrpg },
 	{ "struct android", CTF_K_STRUCT, 4, check_member_android },
 	{ "union nier", CTF_K_UNION, 4, check_member_nier },
@@ -422,6 +430,13 @@
 		}
 
 		for (j = 0; members[j].cmt_type != NULL; j++) {
+			if (ctftest_skip(members[j].cmt_skips)) {
+				warnx("skipping members test %s due to "
+				    "known compiler issue",
+				    members[j].cmt_type);
+				continue;
+			}
+
 			if (!ctftest_check_members(members[j].cmt_type, fp,
 			    members[j].cmt_kind, members[j].cmt_size,
 			    members[j].cmt_members)) {
--- a/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh	Sat Jan 11 11:00:06 2020 +0000
@@ -18,6 +18,14 @@
 
 progname=$(basename $0)
 
+#
+# The assembler and compiler may not end up using the same architecture
+# (e.g. 32-bit or 64-bit) by default. So we force this to always be
+# consistent.
+#
+cflags="-m64"
+asflags="--64"
+
 fail()
 {
 	echo "Failed: $*" 2>&1
@@ -62,12 +70,12 @@
 cat <<EOF >file1.c
 #include <stdio.h>
 struct foo { int a; };
-int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); }
+int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); return (0); }
 EOF
 
 cat <<EOF >file2.c
 #include <stdio.h>
-char myfunc(int a) { printf("%d\n", a); }
+char myfunc(int a) { printf("%d\n", a); return ('a'); }
 EOF
 
 cat <<EOF >file3.cc
@@ -86,34 +94,34 @@
 echo "$progname: An empty file should fail conversion due to no DWARF"
 echo >emptyfile.c
 
-$ctf_cc -c -o emptyfile.o emptyfile.c
+$ctf_cc $cflags -c -o emptyfile.o emptyfile.c
 fail_no_debug emptyfile.o
-$ctf_cc -c -o emptyfile.o emptyfile.c
+$ctf_cc $cflags -c -o emptyfile.o emptyfile.c
 $ctf_convert -m emptyfile.o
 
-$ctf_cc $ctf_debugflags -c -o emptyfile.o emptyfile.c
+$ctf_cc $cflags $ctf_debugflags -c -o emptyfile.o emptyfile.c
 fail_no_debug emptyfile.o
-$ctf_cc $ctf_debugflags -c -o emptyfile.o emptyfile.c
+$ctf_cc $cflags $ctf_debugflags -c -o emptyfile.o emptyfile.c
 $ctf_convert -m emptyfile.o
 
 echo "$progname: A file missing DWARF should fail conversion"
 
-$ctf_cc -c -o file1.o file1.c
+$ctf_cc $cflags -c -o file1.o file1.c
 fail_no_debug file1.o
-$ctf_cc -c -o file1.o file1.c
+$ctf_cc $cflags -c -o file1.o file1.c
 $ctf_convert -m file1.o
 
 echo "$progname: A binary with DWARF but 0 debug dies should fail conversion"
 
-$ctf_cc -o mybin file1.c
+$ctf_cc $cflags -o mybin file1.c
 fail_no_debug mybin
-$ctf_cc -o mybin file1.c
+$ctf_cc $cflags -o mybin file1.c
 $ctf_convert -m mybin
 
 echo "$progname: One C file missing DWARF should fail ctfconvert"
 
-$ctf_cc -c -o file1.o file1.c
-$ctf_cc $ctf_debugflags -c -o file2.o file2.c
+$ctf_cc $cflags -c -o file1.o file1.c
+$ctf_cc $cflags $ctf_debugflags -c -o file2.o file2.c
 ld -r -o files.o file2.o file1.o
 fail_no_debug files.o
 ld -r -o files.o file2.o file1.o
@@ -122,18 +130,18 @@
 
 echo "$progname: One .cc file missing DWARF should pass"
 
-$ctf_cc $ctf_debugflags -c -o file1.o file1.c
-$ctf_cc $ctf_debugflags -c -o file2.o file2.c
-$ctf_cxx -c -o file3.o file3.cc
+$ctf_cc $cflags $ctf_debugflags -c -o file1.o file1.c
+$ctf_cc $cflags $ctf_debugflags -c -o file2.o file2.c
+$ctf_cxx $cflags -c -o file3.o file3.cc
 ld -r -o files.o file1.o file2.o file3.o
 $ctf_convert files.o
 has_ctf files.o
 
 echo "$progname: One .s file missing DWARF should pass"
-$ctf_cc $ctf_debugflags -c -o file1.o file1.c
-$ctf_cc $ctf_debugflags -c -o file2.o file2.c
-$ctf_as -o file4.o file4.s
-$ctf_cc -o mybin file1.o file2.o file4.o
+$ctf_cc $cflags $ctf_debugflags -c -o file1.o file1.c
+$ctf_cc $cflags $ctf_debugflags -c -o file2.o file2.c
+$ctf_as $asflags -o file4.o file4.s
+$ctf_cc $cflags -o mybin file1.o file2.o file4.o
 $ctf_convert mybin
 has_ctf mybin
 
--- a/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh	Sat Jan 11 11:00:06 2020 +0000
@@ -59,7 +59,7 @@
 cat <<EOF >file1.c
 #include <stdio.h>
 struct foo { int a; };
-int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); }
+int main(void) { struct foo foo = { 4 }; printf("%d\n", foo.a); return (0); }
 EOF
 
 cat <<EOF >file2.cc
--- a/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh	Sat Jan 11 11:00:06 2020 +0000
@@ -18,6 +18,14 @@
 
 progname=$(basename $0)
 
+#
+# The assembler and compiler may not end up using the same architecture
+# (e.g. 32-bit or 64-bit) by default. So we force this to always be
+# consistent.
+#
+cflags="-m64"
+asflags="--64"
+
 fail()
 {
 	echo "Failed: $*" 2>&1
@@ -67,7 +75,7 @@
 #include <stdio.h>
 struct foo { char b; float c; };
 struct foo stuff[90];
-char myfunc(int a) { printf("%d\n", a); }
+char myfunc(int a) { printf("%d\n", a); return ('z'); }
 EOF
 
 cat <<EOF >file3.cc
@@ -85,29 +93,29 @@
 
 echo "$progname: ctfmerge should fail if one C-source lacks CTF"
 
-$ctf_cc $ctf_debugflags -c -o file1.o file1.c
+$ctf_cc $cflags $ctf_debugflags -c -o file1.o file1.c
 $ctf_convert file1.o
-$ctf_cc -c -o file2.o file2.c
+$ctf_cc $cflags -c -o file2.o file2.c
 ld -r -o files.o file2.o file1.o
 fail_no_ctf $ctf_merge -o files.o file2.o file1.o
 ld -r -o files.o file2.o file1.o
 $ctf_merge -m -o files.o file2.o file1.o
 has_ctf files.o
-$ctf_cc -o mybin file2.o file1.o
+$ctf_cc $cflags -o mybin file2.o file1.o
 fail_no_ctf $ctf_merge -o mybin file2.o file1.o
-$ctf_cc -o mybin file2.o file1.o
+$ctf_cc $cflags -o mybin file2.o file1.o
 $ctf_merge -m -o mybin file2.o file1.o
 
 
 echo "$progname: ctfmerge should allow a .cc file to lack CTF"
-$ctf_cxx -c -o file3.o file3.cc
+$ctf_cxx $cflags -c -o file3.o file3.cc
 ld -r -o files.o file1.o file3.o
 $ctf_merge -o files.o file1.o file3.o
 ld -r -o files.o file1.o file3.o
 $ctf_merge -m -o files.o file1.o file3.o
 
 echo "$progname: ctfmerge should allow an .s file to lack CTF"
-$ctf_as -o file4.o file4.s
+$ctf_as $asflags -o file4.o file4.s
 ld -r -o files.o file4.o file1.o
 $ctf_merge -o files.o file4.o file1.o
 ld -r -o files.o file4.o file1.o
--- a/usr/src/test/util-tests/tests/ctf/ctftest.ksh	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/ctftest.ksh	Sat Jan 11 11:00:06 2020 +0000
@@ -32,7 +32,7 @@
 ctf_tests=
 ctf_cc="gcc"
 ctf_cxx="g++"
-ctf_as="as"
+ctf_as="gas"
 ctf_convert="ctfconvert"
 ctf_merge="ctfmerge"
 ctf_debugflags="-gdwarf-2 "
@@ -41,6 +41,8 @@
 ctf_temp="$TMPDIR/ctftest.$$.o"
 ctf_makefile="Makefile.ctftest"
 ctf_nerrs=0
+ctf_cc_type=
+ctf_cc_vers=
 
 usage()
 {
@@ -73,20 +75,52 @@
 	((ctf_nerrs++))
 }
 
+warn()
+{
+	typeset msg="$*"
+	echo "$ctf_arg0: $msg" >&2
+}
+
 fatal()
 {
 	typeset msg="$*"
 	[[ -z "$msg" ]] && msg="failed"
 	echo "$ctf_arg0: $msg" >&2
-	rm -f "$ctf_tmp32" "$ctf_temp64"
+	rm -f "$ctf_temp"
 	exit 1
 }
 
+#
+# Attempt to try and figure out what class and version of compiler we
+# are dealing with so we can try and skip known failures due to existing
+# bugs in the compiler.
+#
+determine_compiler()
+{
+	typeset name=$($ctf_cc --version | awk '{ print $1; exit; }')
+	typeset version
+
+	if [[ "$name" == "gcc" ]]; then
+		version=$($ctf_cc --version | awk '{ print $NF; exit; }')
+	elif [[ "$name" == "clang" ]]; then
+		version=$($ctf_cc --version | awk '{ print $NF; exit; }')
+	else
+		warn "failed to parse compiler name from $ctf_cc, will " \
+		    "not make any assumptions about expected failures"
+		name="unknown"
+		version="unknown"
+	fi
+
+	ctf_cc_type="$name"
+	ctf_cc_version="$version"
+}
+
 announce()
 {
 	cat << EOF
 Beginning CTF tests with the following settings:
 cc:		$(which $ctf_cc)
+detected:	$ctf_cc_type $ctf_cc_version
 CC:		$(which $ctf_cxx)
 as:		$(which $ctf_as)
 ctfconvert:	$(which $ctf_convert)
@@ -116,6 +150,7 @@
 		return
 	fi
 
+	rm -f "$ctf_temp"
 	echo "TEST PASSED: $source $flags"
 }
 
@@ -259,7 +294,10 @@
 ctf_32cflags="$ctf_mach32 $ctf_debugflags"
 ctf_64cflags="$ctf_mach64 $ctf_debugflags"
 
+determine_compiler
+
 export ctf_as ctf_cc ctf_cxx ctf_debugflags ctf_merge ctf_convert
+export ctf_cc_type ctf_cc_version
 
 announce
 
--- a/usr/src/test/util-tests/tests/ctf/test-function.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-function.c	Sat Jan 11 11:00:06 2020 +0000
@@ -20,45 +20,45 @@
  * Test various function and function pointer cases.
  */
 
-static void
+void
 simple_func(void)
 {
 }
 
-static void
+void
 one(int v)
 {
 }
 
-static void
+void
 two(int v, const char *a)
 {
 }
 
-static void
+void
 three(int v, const char *a, float b)
 {
 }
 
-static const char *
+const char *
 noarg(void)
 {
 	return ("hello, world");
 }
 
-static const char *
+const char *
 argument(uintptr_t base)
 {
 	return ((const char *)(base + 1));
 }
 
-static void
+void
 vararg(const char *foo, ...)
 {
 
 }
 
-static uintptr_t
+uintptr_t
 vararg_ret(const char *foo, ...)
 {
 	return ((uintptr_t)foo);
--- a/usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest	Sat Jan 11 11:00:06 2020 +0000
@@ -35,5 +35,7 @@
 		$(BUILDDIR)/test-merge-3.64.m.o \
 		$(BUILDDIR)/test-merge-dedup.64.m.o
 
+TEST_CFLAGS32 =	-fcommon
+TEST_CFLAGS64 =	-fcommon
 
 include		../Makefile.ctftest.com
--- a/usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest	Sat Jan 11 11:00:06 2020 +0000
@@ -51,7 +51,7 @@
 
 CFLAGS = -fPIC
 LDFLAGS = -shared -Wl,-Mmapfile-vers -Wl,-ztext -Wl,-zdefs \
-	  -htest-merge-reduction.so.1
+	  -Wl,-htest-merge-reduction.so.1 -lc
 
 build: $(BINS)
 
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c	Sat Jan 11 11:00:06 2020 +0000
@@ -22,3 +22,9 @@
 {
 	return (a);
 }
+
+uint8_t
+a(uint8_t a)
+{
+	return (mumble(a));
+}
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c	Sat Jan 11 11:00:06 2020 +0000
@@ -22,3 +22,9 @@
 {
 	return (a);
 }
+
+uint16_t
+b(uint16_t b)
+{
+	return (mumble(b));
+}
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c	Sat Jan 11 11:00:06 2020 +0000
@@ -22,3 +22,9 @@
 {
 	return (a);
 }
+
+uint32_t
+c(uint16_t c)
+{
+	return (mumble(c));
+}
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c	Sat Jan 11 11:00:06 2020 +0000
@@ -22,3 +22,9 @@
 {
 	return (a);
 }
+
+uint64_t
+d(uint64_t d)
+{
+	return (mumble(d));
+}
--- a/usr/src/test/util-tests/tests/ctf/test-sou.c	Mon Oct 12 12:01:29 2020 +0100
+++ b/usr/src/test/util-tests/tests/ctf/test-sou.c	Sat Jan 11 11:00:06 2020 +0000
@@ -238,9 +238,18 @@
 struct trigger ct;
 
 /*
- * This is an array/union combo that failed conversion previously.
+ * This is an array/union combo that failed conversion previously. Because it is
+ * static, we need to have a dummy function to make sure that clang doesn't
+ * optimize it away. Hopefully even with optimizations, this'll still be kept
+ * even though it's a constant.
  */
 static const union regress {
 	unsigned int i[3];
 	long double e;
 } regress[9];
+
+unsigned int
+get_regress(void)
+{
+	return (regress[0].i[2]);
+}