QProcess/FreeBSD: remove the workaround allowing undefined symbols

On FreeBSD, the environ variable doesn't come from libc, but is instead
inserted during linking. See ccf74b5928
(5.6) for more information.

But instead of allowing undefined symbols in QtCore, let's use a weakref
to environ so this one symbol is allowed to be undefined. It won't be,
but the linker doesn't know.

FreeBSD appears to be the only BSD to require this. We used to apply the
same linker option to OpenBSD in Qt 5, but neither the OpenBSD or nor
the NetBSD ports trees[1][2] carry a patch for this, so I don't think
it's necessary.

[1] https://github.com/openbsd/ports/tree/master/x11/qt6/qtbase/patches
[2] https://github.com/NetBSD/pkgsrc/tree/trunk/x11/qt6-qtbase/patches

Pick-to: 6.6
Change-Id: I63b988479db546dabffcfffd17661c839014771a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Thiago Macieira 2023-06-06 08:47:41 -07:00
parent 44b5ad01f0
commit 166e792269
2 changed files with 5 additions and 12 deletions

View File

@ -479,14 +479,6 @@ qt_internal_extend_target(Core CONDITION MSVC AND (TEST_architecture_arch STREQU
"/BASE:0x67000000" "/BASE:0x67000000"
) )
# QtCore can't be compiled with -Wl,-no-undefined because it uses the
# "environ" variable and FreeBSD does not include a weak symbol for it
# in libc.
qt_internal_extend_target(Core CONDITION FREEBSD
LINK_OPTIONS
"LINKER:--warn-unresolved-symbols"
)
qt_internal_extend_target(Core CONDITION QT_FEATURE_xmlstream qt_internal_extend_target(Core CONDITION QT_FEATURE_xmlstream
SOURCES SOURCES
serialization/qxmlstream.cpp serialization/qxmlstream.h serialization/qxmlstream_p.h serialization/qxmlstream.cpp serialization/qxmlstream.h serialization/qxmlstream_p.h

View File

@ -52,6 +52,11 @@
# define O_PATH 0 # define O_PATH 0
#endif #endif
#ifdef Q_OS_FREEBSD
__attribute__((weak))
#endif
extern char **environ;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals; using namespace Qt::StringLiterals;
@ -80,10 +85,6 @@ struct PThreadCancelGuard
#if !defined(Q_OS_DARWIN) #if !defined(Q_OS_DARWIN)
QT_BEGIN_INCLUDE_NAMESPACE
extern char **environ;
QT_END_INCLUDE_NAMESPACE
QProcessEnvironment QProcessEnvironment::systemEnvironment() QProcessEnvironment QProcessEnvironment::systemEnvironment()
{ {
QProcessEnvironment env; QProcessEnvironment env;