* [ptxdist] [PATCH] Fixed broken httpd build (undefined reference to crypt_r)
@ 2015-07-09 9:35 Stefan Kratochwil
2015-07-09 11:03 ` Juergen Borleis
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Kratochwil @ 2015-07-09 9:35 UTC (permalink / raw)
To: ptxdist
Hi,
I fixed a problem regarding the httpd build. Without this fix, the build crashes during linking several binaries from the <httpd-basedir>/support subdir, including htdigest etc. The error message was 'undefined reference to crypt_r'.
This has been introduced by a changed behaviour in newer gcc versions, which by default set the linker option -Wl--as-needed. This results in WEAK symbol references not being resolved properly in certain situations. Linking against libcrypt turned out to be a main trigger for this problem.
The solution is to add -Wl--no-as-needed to ALL_LDFLAGS:
commit 8ecb56b24b57a0b2aca1470f48f60a34f518beaf
Author: Stefan Kratochwil <stefankratochwil@inovel.de>
Date: Wed Jul 8 16:02:23 2015 +0200
Fixed undefined reference to crypt_r.
Newer gcc versions used the linker option -Wl--no-as-needed by default.
This behaviour was changed in newer versions, which default to
-Wl--as-needed.
This leads to WEAK symbols not being resolved properly, which itself
leads to linking errors, especially if libcrypt is involved.
This patch restores the original behaviour by adding the linker option
-Wl--no-as-needed to ALL_LDFLAGS.
diff --git a/patches/httpd-2.0.64/0005-fix-undefined-reference-to-crypt_r-by-no-as-needed.patch b/patches/httpd-2.0.64/0005-fix-undefined-reference-to-crypt_r-by-no-as-needed.patch
new file mode 100755
index 0000000..e80637f
--- /dev/null
+++ b/patches/httpd-2.0.64/0005-fix-undefined-reference-to-crypt_r-by-no-as-needed.patch
+Index: httpd-2.0.64/build/rules.mk.in
+===================================================================
+--- httpd-2.0.64.orig/build/rules.mk.in 2006-07-12 09:40:55.000000000 +0200
++++ httpd-2.0.64/build/rules.mk.in 2015-07-08 11:16:05.521218188 +0200
+
+ ALL_CFLAGS = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS)
+ ALL_CPPFLAGS = $(DEFS) $(EXTRA_CPPFLAGS) $(NOTEST_CPPFLAGS) $(CPPFLAGS)
+ ALL_CXXFLAGS = $(EXTRA_CXXFLAGS) $(NOTEST_CXXFLAGS) $(CXXFLAGS)
+-ALL_LDFLAGS = $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS)
++ALL_LDFLAGS = -Wl,--no-as-needed $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS)
+ ALL_LIBS = $(EXTRA_LIBS) $(NOTEST_LIBS) $(LIBS)
+ ALL_INCLUDES = $(INCLUDES) $(EXTRA_INCLUDES)
+
diff --git a/patches/httpd-2.0.64/series b/patches/httpd-2.0.64/series
index ff12a99..ff03f1f 100644
--- a/patches/httpd-2.0.64/series
+++ b/patches/httpd-2.0.64/series
0003-HACK-support-apxs-don-t-execute-httpd.patch
0004-HACK-support-apxs-don-t-try-to-modify-the-config-fil.patch
# 160b9c105b4f55538cd0ce5c82eda8fd - git-ptx-patches magic
+0005-fix-undefined-reference-to-crypt_r-by-no-as-needed.patch
I have no idea since when this problem occurs, but I recall a posting her on the mailinglist from a few years ago, stating that the build worked with OSELAS.Toolchain() 2012.xx.yy, but got broken with a later version.
Note: this problem also occurs in lighthttpd, and possibly in several other packages! I do not have a patch for lighthttpd and also didn't look for other affected packages.
I would be happy about a few comments.
Mit freundlichen Grüßen / with best regards
stefan kratochwil
future master of software engineering
inovel elektronik gmbh
inovel systeme AG
gebhardstr. 7
88046 friedrichshafen
phone +49 7541 39900-0
fax +49 7541 39900-99
mail stefankratochwil@inovel.de
web www.inovel.de
inovel elektronik gmbh
general manager: axel dittus, robert steinhauser
hrb 632191 amtsgericht ulm; VAT Reg. No.: DE811926597
inovel systeme AG
board of management: markus spinnenhirn (chairman), axel dittus, robert steinhauser
chairman of the supervisory board: joachim zodel
registered office: friedrichshafen; hrb 728443 amtsgericht ulm; VAT Reg. No.: DE814611877
This email (including any attachments) may contain confidential and/or privileged information or information otherwise
protected from disclosure. If you are not the intended recipient, please notify the sender immediately, do not copy this
message or any attachments and do not use it for any purpose or disclose its content to any person, but delete this
message and any attachments from your system. inovel disclaims any and all liability if this email transmission was virus
corrupted, altered or falsified.
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ptxdist] [PATCH] Fixed broken httpd build (undefined reference to crypt_r)
2015-07-09 9:35 [ptxdist] [PATCH] Fixed broken httpd build (undefined reference to crypt_r) Stefan Kratochwil
@ 2015-07-09 11:03 ` Juergen Borleis
0 siblings, 0 replies; 2+ messages in thread
From: Juergen Borleis @ 2015-07-09 11:03 UTC (permalink / raw)
To: ptxdist; +Cc: Stefan Kratochwil
Hi Stefan,
On Thursday 09 July 2015 11:35:40 Stefan Kratochwil wrote:
> I fixed a problem regarding the httpd build. Without this fix, the build
> crashes during linking several binaries from the <httpd-basedir>/support
> subdir, including htdigest etc. The error message was 'undefined reference
> to crypt_r'.
>
> This has been introduced by a changed behaviour in newer gcc versions,
> which by default set the linker option -Wl--as-needed. This results in WEAK
> symbol references not being resolved properly in certain situations.
> Linking against libcrypt turned out to be a main trigger for this problem.
>
> The solution is to add -Wl--no-as-needed to ALL_LDFLAGS:
After a discussion here your fix isn't a real fix, it is just a workaround.
Alternatively you can add a
APACHE2_WRAPPER_BLACKLIST := TARGET_LINKER_AS_NEEDED
to your apache rule file. This will prevent the compiler wrappers from
forwarding the global "-Wl--as-needed" option to this specific package.
But:
With the "-Wl--as-needed" switch each component is linked against only those
libraries it really uses. In the reported build failure from February 6th 2015
the main program "httxt2dbm" was linked against "libcrypt" and "libaprutil-0".
In the "--no-as-needed" case "httxt2dbm" gets linked against "libcrypt", even
if it *does not* use any symbol from this library:
httxt2dbm
-> libcrypt
-> libaprutil-0
-> calls "crypt_r()" from libcrypt
In the "--as-needed" case the linker sorts out libcrypt, because "httxt2dbm"
does not use any symbol from this library:
httxt2dbm
-> libaprutil-0
-> calls "crypt_r()" and fails
Using "--as-needed" is a correct approach, because it forces you to do things
right: ensure your component is linked agains everything it needs.
httxt2dbm
-> libaprutil-0
-> libcrypt
-> calls "crypt_r()" from libcrypt
The correct fix is: ensure the component libaprutil-0 is linked
against "libcrypt" because it uses "crypt_r()".
Regards,
Juergen
--
Pengutronix e.K. | Juergen Borleis |
Linux Solutions for Science and Industry | Phone: +49-5121-206917-5128 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ |
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-09 11:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-09 9:35 [ptxdist] [PATCH] Fixed broken httpd build (undefined reference to crypt_r) Stefan Kratochwil
2015-07-09 11:03 ` Juergen Borleis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox