/usr/src/tools/test/dtrace/../../../cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c:49:2: warning: implicit declaration of function '_go' is invalid in C99 [-Wimplicit-function-declaration] _go(1); ^ /usr/src/tools/test/dtrace/../../../cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c:38:14: warning: weak identifier 'go' never declared #pragma weak _go = go ^ 2 warnings generated. /tmp/tst-f5fc99.o: In function `handle': /usr/src/tools/test/dtrace/../../../cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c:(.text+0x5d): undefined reference to `_go' cc: error: linker command failed with exit code 1 (use -v to see invocation) *** Error code 1 Stop. make: stopped in /usr/src/tools/test/dtrace Here's a full diff of what needs to be massaged for clang and to integrate the test suite into ATF/kyua: https://github.com/yaneurabeya/freebsd/pull/11
This can be fixed quite easily by moving the pragma to after the definition of go() in tst.weak2.c. That is, the following compiles: static void go(int a) { ... } #pragma weak _go = go But note that tst.weak1.c is identical except for the fact that go() is not local, and it compiles without errors. So this could be a bug in clang, I'm not sure. Note that the following also compiles: void _go(int a) __attribute__((weak, alias("go"))); static void go(int a) { ... }
It seems to me that this is a minor clang bug. I submitted a PR here: http://llvm.org/bugs/show_bug.cgi?id=20948 For now I think it's best to just commit the workaround I suggested earlier.
A commit references this bug: Author: markj Date: Wed Sep 17 04:02:56 UTC 2014 New revision: 271699 URL: http://svnweb.freebsd.org/changeset/base/271699 Log: Implement a workaround to allow this test program to be compiled with clang. It seems that if a pragma is used to define a weak alias for a local function, the pragma must appear after the function is defined. PR: 193056 MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Changes: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c
Close PRs that have had a corresponding fix committed.
A commit references this bug: Author: ngie Date: Thu Feb 9 22:04:58 UTC 2017 New revision: 313486 URL: https://svnweb.freebsd.org/changeset/base/313486 Log: MFC r258903,r264487,r271699,r288415: r258903 (by markj): Enable some previously-disabled DTrace tests for umod, ufunc and usym. They expect the installed ksh binary to be named "ksh", which is not the case when it's installed on FreeBSD via the shells/ksh93 port. Allow for it to be "ksh93" as well so that the tests can actually pass. r264487 (by markj): Replace a few Solarisisms with their corresponding FreeBSDisms to make a few printf tests pass. r271699 (by markj): Implement a workaround to allow this test program to be compiled with clang. It seems that if a pragma is used to define a weak alias for a local function, the pragma must appear after the function is defined. PR: 193056 r288415 (by markj): MFV r288408: 6266 harden dtrace_difo_chunksize() with respect to malicious DIF illumos/illumos-gate@395c7a3dcfc66b8b671dc4b3c4a2f0ca26449922 Author: Bryan Cantrill <bryan@joyent.com> Changes: _U stable/10/ stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.basics.d.out stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.str.d.out stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/printf/tst.sym.d.out stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.kpriv.ksh stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ufunc.ksh stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.umod.ksh stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.usym.ksh stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.bigglobal.d stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/scalars/err.biglocal.d stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h stable/10/tools/test/dtrace/Makefile