mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Juergen Borleis <jbe@pengutronix.de>
To: ptxdist@pengutronix.de
Cc: Stefan Kratochwil <stefankratochwil@inovel.de>
Subject: Re: [ptxdist] [PATCH] Fixed broken httpd build (undefined reference to crypt_r)
Date: Thu, 9 Jul 2015 13:03:34 +0200	[thread overview]
Message-ID: <201507091303.34175.jbe@pengutronix.de> (raw)
In-Reply-To: <00050B79.559E5C8B@mail.ino.local>

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

      reply	other threads:[~2015-07-09 11:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09  9:35 Stefan Kratochwil
2015-07-09 11:03 ` Juergen Borleis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201507091303.34175.jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    --cc=stefankratochwil@inovel.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox