You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fails to link if libpng/jpeg development libraries are missing.
When compiling Tk 804.036, the following warning appears when configuring: 'pkg-config libpng' failed, continue with fallback values for cflags and libs...
This is because I have libpng16-devel installed which has libpng16.pc instead of plain libpng.pc. Because libpng was not found, the build system attempts to compile the bundled libpng. My brewed perl was compiled with _FORTIFY_SOURCE and -O2 and the build system picks up the _FORTIFY_SOURCE option, but ignores the optimization flag when compiling libpng/jpeg. This leads to the following warning when checking for <errno.h> in PNG/zlib/configure:405:
cc -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/inclu
de -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -o example test.c
In file included from /usr/include/errno.h:25,
from test.c:1:
/usr/include/features.h:414:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
| ^~~~~~~
As configure checks the compiler output against the empty string, it assumes that <errno.h> is not found, defining the NO_ERRNO_H macro. This leads to the errno global variable being declared in PNG/zlib/zutil.h:35. This non-thread local storage variable declaration clashes with the TLS definition in the version of glibc I have installed (which is 2.39), leading to the following error when linking:
> cc -fPIC -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -fPIC -DNO_snprintf -DHAS_sprintf_void -DNO_ERRNO_H -o example example.o -L. libz.a
/usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: errno: TLS definition in /lib64/libc.so.6 section .tbss mismatches non-TLS reference in libz.a(gzio.o)
/usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: /lib64/libc.so.6: error adding symbols: bad value
The fix is simple: Enable optimization by adding $Config{optimize} flag, which was -O2 on the Perl I brewed, to the CFLAGS for the bundled libpng and jpeg so that _FORTIFY_SOURCE, which was added to Perl's build system starting in 5.22, doesn't cause a warning.
diff --git a/JPEG/Makefile.jpeg.maybe b/JPEG/Makefile.jpeg.maybe
index 7bb9688b..063e53d3 100755
--- a/JPEG/Makefile.jpeg.maybe+++ b/JPEG/Makefile.jpeg.maybe@@ -32,7 +32,7 @@ if ($^O eq 'MSWin32')
else
{
$ENV{CC} = $Config{cc};
- local $ENV{CFLAGS} = "$Config{ccflags} $Config{cccdlflags}";+ local $ENV{CFLAGS} = "$Config{ccflags} $Config{optimize} $Config{cccdlflags}";
local $ENV{LDFLAGS} = "$Config{ccflags} $Config{ldflags}";
system(sh => "./configure");
}
diff --git a/PNG/Makefile.zlib.maybe b/PNG/Makefile.zlib.maybe
index 6da4ba9a..abe519b8 100644
--- a/PNG/Makefile.zlib.maybe+++ b/PNG/Makefile.zlib.maybe@@ -26,7 +26,7 @@ if ($^O eq 'MSWin32')
else
{
$ENV{CC} = $Config{cc};
- local $ENV{CFLAGS} = "$Config{ccflags} $Config{cccdlflags}";+ local $ENV{CFLAGS} = "$Config{ccflags} $Config{optimize} $Config{cccdlflags}";
system(sh => "./configure");
}
VERSIONS
Perl 5.41.2 (installed from source with Perlbrew)
CPAN: 1.64
GCC 13.3.0 (official Tumbleweed package)
GLIBC 2.39 (official Tumbleweed package)
openSUSE Tumbleweed 20240725-0 (Last month's snapshot)
perl-Tk version: 804.036-18-gf0bb386b
libPNG: libpng16-16 libpng16-devel
libJPEG: libjpeg8 (don't have -devel package installed at the moment) ld.bfd version: GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-4
WSL2 version:
If libPNG and/or JPEG libraries are not installed and Perl was compiled
with -D_FORTIFY_SOURCE, the linker will fail with a mismatched errno
error. This is caused by GCC outputting a warning when Perl/Tk's build system
picks up on the _FORTIFY_SOURCE option but not the optimization option.
The configure script checks the compiler output against the empty
string, so the warning causes it to assume there is no errno.h on the
system.
Fixeseserte#109.
Fails to link if libpng/jpeg development libraries are missing.
When compiling Tk 804.036, the following warning appears when configuring:
'pkg-config libpng' failed, continue with fallback values for cflags and libs...
This is because I have libpng16-devel installed which has libpng16.pc instead of plain libpng.pc. Because libpng was not found, the build system attempts to compile the bundled libpng. My brewed perl was compiled with _FORTIFY_SOURCE and -O2 and the build system picks up the _FORTIFY_SOURCE option, but ignores the optimization flag when compiling libpng/jpeg. This leads to the following warning when checking for
<errno.h>
in PNG/zlib/configure:405:As configure checks the compiler output against the empty string, it assumes that <errno.h> is not found, defining the NO_ERRNO_H macro. This leads to the
errno
global variable being declared in PNG/zlib/zutil.h:35. This non-thread local storage variable declaration clashes with the TLS definition in the version of glibc I have installed (which is 2.39), leading to the following error when linking:The fix is simple: Enable optimization by adding
$Config{optimize}
flag, which was-O2
on the Perl I brewed, to the CFLAGS for the bundled libpng and jpeg so that_FORTIFY_SOURCE
, which was added to Perl's build system starting in 5.22, doesn't cause a warning.VERSIONS
Perl 5.41.2 (installed from source with Perlbrew)
CPAN: 1.64
GCC 13.3.0 (official Tumbleweed package)
GLIBC 2.39 (official Tumbleweed package)
openSUSE Tumbleweed 20240725-0 (Last month's snapshot)
perl-Tk version: 804.036-18-gf0bb386b
libPNG: libpng16-16 libpng16-devel
libJPEG: libjpeg8 (don't have -devel package installed at the moment)
ld.bfd
version: GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.42.0.20240130-4WSL2 version:
perl -V
The text was updated successfully, but these errors were encountered: