Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[tcl] unix build of the 8.5 branch fails to build on Mac OS X with LTO (-flto)

Closed / Wont Fix4d72a5f77f268c6882d974562e53a34354273a31Created 10 years agoUpdated 3 years ago
Descriptionplain2016-09-13 14:57:19
I don't think I ever got around reporting this issue here:

Building the generic Unix flavour of Tcl 8.5 on OS X (as done for instance by MacPorts to obtain the interpreter driving the entire build/packaging system) fails when using Link-Time Optimisation (-flto compiler/linker option).

When this option is used, the Tcl build system erroneously detects the presence of the pthread_attr_get_np() function which exists only on Linux; as a result, compilation fails on #include <pthread_np.h> .

This issue boils down to a failing conftest.c programme generated by the configure script (and I think specified by the tcl.m4 file). In essence, this test does

main () {
    char pthread_attr_get_np();
    char (*f)() = pthread_attr_get_np;
    return f != pthread_attr_get_np;
}

Semantically, the actual value of f is moot in the boolean expression, which in fact can only evaluate to false. With LTO activated, clang recognises this fact, suppresses the reference to the actual function and as a result does not fail to link when that function isn't available.

Adding a call to a function with side-effects (unknown to the linker, such as printf("%p", pthread_attr_get_np); restores the expected behaviour (i.e. the link step fails, and thus the test also).
chrstphrchvzwiki2023-08-15 08:19:33

Should this be closed as won’t-fix for 8.5?

MacPorts has since migrated from Tcl 8.5.19 to 8.6.12 in their 2.8.0 release. The test for pthread_attr_get_np() in tcl.m4 was removed in [626938b63a77] (8.6a2). If LTO is still broken in 8.6 then it is not because of that specific test.

jan.nijtmansplain2023-09-14 07:00:41
Closing as Won't-fix for 8.5
Log in (anonymous is fine) to add a comment.