summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2020-12-15 10:46:38 -0500
committerDan McDonald <danmcd@joyent.com>2020-12-15 10:46:38 -0500
commit713214ca24ba6751e1efb771ff75745f3518ee93 (patch)
treec18c6f33c27809a16bedfde18cae1e2978e60eb2
parentfbbddd469d9daea7e493dd9ae6ad2861372aed18 (diff)
parent3cec98229bf077e97e442c942c2bd8768e277449 (diff)
downloadillumos-joyent-713214ca24ba6751e1efb771ff75745f3518ee93.tar.gz
[illumos-gate merge]
commit 3cec98229bf077e97e442c942c2bd8768e277449 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
-rw-r--r--usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com16
-rw-r--r--usr/src/test/util-tests/tests/ctf/check-common.c26
-rw-r--r--usr/src/test/util-tests/tests/ctf/check-common.h17
-rw-r--r--usr/src/test/util-tests/tests/ctf/check-qualifiers.c43
-rw-r--r--usr/src/test/util-tests/tests/ctf/check-sou.c19
-rw-r--r--usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh46
-rwxr-xr-xusr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh2
-rw-r--r--usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh22
-rw-r--r--usr/src/test/util-tests/tests/ctf/ctftest.ksh42
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-function.c16
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest2
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest2
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c6
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c6
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c6
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c6
-rw-r--r--usr/src/test/util-tests/tests/ctf/test-sou.c11
17 files changed, 239 insertions, 49 deletions
diff --git a/usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com b/usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com
index f3f754dbf9..d1cdebb110 100644
--- a/usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com
+++ b/usr/src/test/util-tests/tests/ctf/Makefile.ctftest.com
@@ -56,33 +56,33 @@ BINS = $(CONV32) \
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:
diff --git a/usr/src/test/util-tests/tests/ctf/check-common.c b/usr/src/test/util-tests/tests/ctf/check-common.c
index 9b83f70ebd..60e9799fef 100644
--- a/usr/src/test/util-tests/tests/ctf/check-common.c
+++ b/usr/src/test/util-tests/tests/ctf/check-common.c
@@ -142,6 +142,12 @@ ctftest_check_numbers(ctf_file_t *fp, const check_number_t *tests)
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 @@ ctftest_duplicates(ctf_file_t *fp)
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);
+}
diff --git a/usr/src/test/util-tests/tests/ctf/check-common.h b/usr/src/test/util-tests/tests/ctf/check-common.h
index efb848d25b..032c40b093 100644
--- a/usr/src/test/util-tests/tests/ctf/check-common.h
+++ b/usr/src/test/util-tests/tests/ctf/check-common.h
@@ -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 @@ typedef struct check_member_test {
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_check_size(const char *, ctf_file_t *, size_t);
*/
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
diff --git a/usr/src/test/util-tests/tests/ctf/check-qualifiers.c b/usr/src/test/util-tests/tests/ctf/check-qualifiers.c
index bd619a94c0..7c0ddaa0e1 100644
--- a/usr/src/test/util-tests/tests/ctf/check-qualifiers.c
+++ b/usr/src/test/util-tests/tests/ctf/check-qualifiers.c
@@ -120,9 +120,18 @@ static check_descent_t check_descent_cv_int_array_gcc7[] = {
{ 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 @@ static check_descent_t check_descent_vc_int_array_gcc7[] = {
{ 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 @@ static check_descent_t check_descent_vc_int_array2_gcc7[] = {
{ 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 @@ static check_descent_t check_descent_cv_3d_array_gcc7[] = {
{ 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 }
};
diff --git a/usr/src/test/util-tests/tests/ctf/check-sou.c b/usr/src/test/util-tests/tests/ctf/check-sou.c
index e991452ce2..6b3759daa5 100644
--- a/usr/src/test/util-tests/tests/ctf/check-sou.c
+++ b/usr/src/test/util-tests/tests/ctf/check-sou.c
@@ -41,7 +41,11 @@ static check_number_t check_bitfields[] = {
#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 @@ static check_member_t check_member_rings[] = {
{ 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 @@ static check_member_test_t members[] = {
{ "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 @@ main(int argc, char *argv[])
}
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)) {
diff --git a/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh b/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh
index 2183696aba..0db8179476 100644
--- a/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh
+++ b/usr/src/test/util-tests/tests/ctf/ctftest-convert-no-dwarf.ksh
@@ -18,6 +18,14 @@ result=0
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 @@ has_ctf()
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 @@ EOF
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 @@ has_ctf files.o
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
diff --git a/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh b/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh
index cfbdf3d724..566f082e04 100755
--- a/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh
+++ b/usr/src/test/util-tests/tests/ctf/ctftest-convert-non-c.ksh
@@ -59,7 +59,7 @@ no_ctf()
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
diff --git a/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh b/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh
index ac27c08d6c..c9d86ec345 100644
--- a/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh
+++ b/usr/src/test/util-tests/tests/ctf/ctftest-merge-no-ctf.ksh
@@ -18,6 +18,14 @@ result=0
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 @@ cat <<EOF >file2.c
#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 @@ EOF
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
diff --git a/usr/src/test/util-tests/tests/ctf/ctftest.ksh b/usr/src/test/util-tests/tests/ctf/ctftest.ksh
index 6ed9ca76db..bfb3740562 100644
--- a/usr/src/test/util-tests/tests/ctf/ctftest.ksh
+++ b/usr/src/test/util-tests/tests/ctf/ctftest.ksh
@@ -32,7 +32,7 @@ ctf_root=$(cd $(dirname $0) && echo $PWD)
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_mach64="-m64"
ctf_temp="$TMPDIR/ctftest.$$.o"
ctf_makefile="Makefile.ctftest"
ctf_nerrs=0
+ctf_cc_type=
+ctf_cc_vers=
usage()
{
@@ -73,20 +75,52 @@ test_fail()
((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 @@ run_one()
return
fi
+ rm -f "$ctf_temp"
echo "TEST PASSED: $source $flags"
}
@@ -259,7 +294,10 @@ done
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
diff --git a/usr/src/test/util-tests/tests/ctf/test-function.c b/usr/src/test/util-tests/tests/ctf/test-function.c
index af999b5c78..70d2f84721 100644
--- a/usr/src/test/util-tests/tests/ctf/test-function.c
+++ b/usr/src/test/util-tests/tests/ctf/test-function.c
@@ -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);
diff --git a/usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest b/usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest
index e19e461a1a..d40a8ff118 100644
--- a/usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-dedup/Makefile.ctftest
@@ -35,5 +35,7 @@ OBJS_M_64 = $(BUILDDIR)/test-merge-1.64.m.o \
$(BUILDDIR)/test-merge-3.64.m.o \
$(BUILDDIR)/test-merge-dedup.64.m.o
+TEST_CFLAGS32 = -fcommon
+TEST_CFLAGS64 = -fcommon
include ../Makefile.ctftest.com
diff --git a/usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest b/usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest
index 3cf1fd647f..5e8f72464d 100644
--- a/usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-reduction/Makefile.ctftest
@@ -51,7 +51,7 @@ BINS = $(BUILDDIR)/test-merge-reduction-32c.so.1 \
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)
diff --git a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c
index 749e9fbd22..c03c0e0809 100644
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-a.c
@@ -22,3 +22,9 @@ mumble(uint8_t a)
{
return (a);
}
+
+uint8_t
+a(uint8_t a)
+{
+ return (mumble(a));
+}
diff --git a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c
index 7fca620966..aa1284ba97 100644
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-b.c
@@ -22,3 +22,9 @@ mumble(uint16_t a)
{
return (a);
}
+
+uint16_t
+b(uint16_t b)
+{
+ return (mumble(b));
+}
diff --git a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c
index 2627cec22c..1ae0bd1586 100644
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-c.c
@@ -22,3 +22,9 @@ mumble(uint32_t a)
{
return (a);
}
+
+uint32_t
+c(uint16_t c)
+{
+ return (mumble(c));
+}
diff --git a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c
index 516b6c2fa2..e97a7f807d 100644
--- a/usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c
+++ b/usr/src/test/util-tests/tests/ctf/test-merge-static/test-d.c
@@ -22,3 +22,9 @@ mumble(uint64_t a)
{
return (a);
}
+
+uint64_t
+d(uint64_t d)
+{
+ return (mumble(d));
+}
diff --git a/usr/src/test/util-tests/tests/ctf/test-sou.c b/usr/src/test/util-tests/tests/ctf/test-sou.c
index 8194248df5..232a9e9124 100644
--- a/usr/src/test/util-tests/tests/ctf/test-sou.c
+++ b/usr/src/test/util-tests/tests/ctf/test-sou.c
@@ -238,9 +238,18 @@ struct trigger {
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]);
+}