Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 505508 - net-misc/dhcpcd: configure script is not choosing compiler correctly
Summary: net-misc/dhcpcd: configure script is not choosing compiler correctly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-23 22:59 UTC by William Hubbs
Modified: 2014-04-20 23:23 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
dhcpcd-6.3.1-r1.log (dhcpcd-6.3.1-r1.log,14.07 KB, text/plain)
2014-03-23 23:01 UTC, William Hubbs
Details
dhcpcd-6.3.2.log (dhcpcd-6.3.2.log,13.42 KB, text/plain)
2014-03-23 23:02 UTC, William Hubbs
Details
fix-compiler.patch (fix-compiler.patch,528 bytes, patch)
2014-03-24 00:03 UTC, William Hubbs
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description William Hubbs gentoo-dev 2014-03-23 22:59:28 UTC
Roy,

somewhere between dhcpcd-6.3.1 and dhcpcd-6.3.2, the configure script
was changed so that it does not set the compiler correctly.

I'll attach build logs for dhcpcd-6.3.1-r1 and 6.3.2.
Comment 1 William Hubbs gentoo-dev 2014-03-23 23:01:23 UTC
Created attachment 373372 [details]
dhcpcd-6.3.1-r1.log

Notice which compiler the configure script is using in this version.
Comment 2 William Hubbs gentoo-dev 2014-03-23 23:02:38 UTC
Created attachment 373374 [details]
dhcpcd-6.3.2.log

Notice that the compiler changed in this version.
This is a regression.
Comment 3 William Hubbs gentoo-dev 2014-03-23 23:21:34 UTC
Roy,

It turns out that a downstream fix was added both to 6.3.1-r1 and 6.3.2
without reporting this to you.

I am working on a patch.
Comment 4 Mike Gilbert gentoo-dev 2014-03-23 23:25:32 UTC
To clarify: the build system no longer uses the host-prefixed compiler by default.

This was probably introduced by this check-in:

http://roy.marples.name/projects/dhcpcd/info/82cd85d0eb
Comment 5 Roy Marples 2014-03-23 23:43:59 UTC
This change was made so that the clang static analyzer can be used easily like so

./configure
scan-build make
Comment 6 Roy Marples 2014-03-23 23:45:02 UTC
So, if CC is not passed to configure then we assume cc in $PATH just like default make $CC variable. That kinda made sense unless anyway can poke a hole in it.
Comment 7 Mike Gilbert gentoo-dev 2014-03-23 23:53:08 UTC
It's just a bit strange to those of us who are used to the autoconf behavior.

To use your own example, I imagine this would work for your "clang static analyzer" use case:

export CC=clang
./configure
scan-build make
Comment 8 Mike Gilbert gentoo-dev 2014-03-23 23:55:35 UTC
One further point of clarification: autoconf uses CC if it is set, and otherwise falls back on HOST-gcc, gcc and finally cc. I think that's the behavior most people would expect.
Comment 9 William Hubbs gentoo-dev 2014-03-24 00:03:56 UTC
Created attachment 373380 [details, diff]
fix-compiler.patch

Roy,

here is a patch that would take care of this issue I believe.

The problem is that if CC is not in the env, you force it to cc, which
is not correct.
Comment 10 Roy Marples 2014-03-24 00:11:40 UTC
Yeah, so that's configure forcing CC on make,(In reply to Mike Gilbert from comment #8)
> One further point of clarification: autoconf uses CC if it is set, and
> otherwise falls back on HOST-gcc, gcc and finally cc. I think that's the
> behavior most people would expect.

HOST-cc *should* be cc in $PATH.
If there is no cc in $PATH then we play find the compiler.

But this is a moot point.
Is there a reason why Gentoo cannot export CC in either the configure or make phase?
Comment 11 Roy Marples 2014-03-24 00:20:48 UTC
(In reply to William Hubbs from comment #9)
> The problem is that if CC is not in the env, you force it to cc, which
> is not correct.

I disagree. cc is supposed to be the default host compiler, which can be changed via CC environment variable.

If you think otherwise then why does Gentoo install cc in the first place?
Comment 12 Mike Gilbert gentoo-dev 2014-03-24 00:27:11 UTC
(In reply to Roy Marples from comment #10)
> Is there a reason why Gentoo cannot export CC in either the configure or
> make phase?

No reason at all; the latest ebuild already does that.

> I disagree. cc is supposed to be the default host compiler, which can be changed via CC environment variable.

Why bother supporting the --build, --host, and --target options then? You are pretending to be autotools, but doing it incompletely.
Comment 13 Roy Marples 2014-03-24 00:31:21 UTC
(In reply to Mike Gilbert from comment #12)
> Why bother supporting the --build, --host, and --target options then? You
> are pretending to be autotools, but doing it incompletely.

That is a good point. If any of those flags are set then CC should be set in configure. Anyone care to patch that as I'm about to hit the hay?
Comment 14 William Hubbs gentoo-dev 2014-03-24 00:49:24 UTC
I am willing to do the patch, what should the rules be for setting CC in
that case?
Comment 15 William Hubbs gentoo-dev 2014-03-24 00:55:51 UTC
I'm not sure what happened to an earlier comment I posted, but I did attempt something else that should have worked but got nowhere.

According to the message from your configure script, I should be able to do this:

configure CC="$(tc-getCC)"

but that fails. Should it?
Comment 16 Mike Gilbert gentoo-dev 2014-03-24 01:00:46 UTC
(In reply to Roy Marples from comment #13)
> That is a good point. If any of those flags are set then CC should be set in
> configure. Anyone care to patch that as I'm about to hit the hay?

If CC is set in the environment we should use it unconditionally; this allows the user to pass a valid --host triplet while also using a compiler which may not utilize the GNU naming convention. Again, this is standard autoconf behavior.

William's patch is pretty close. I would just reverse the order of $HOST-gcc and clang (putting $HOST-gcc first).
Comment 17 Roy Marples 2014-03-24 11:24:21 UTC
Does this patch work for you? I think it meets my view at least.
http://roy.marples.name/projects/dhcpcd/ci/8d65cb3139?sbs=0
Comment 18 Mike Gilbert gentoo-dev 2014-03-24 16:54:35 UTC
Not quite. Here's a cross-compile example:

./configure --build=x86_64-pc-linux-gnu --host=armv7a-hardfloat-linux-gnueabi

This outputs:

Using compiler .. /usr/bin/x86_64-pc-linux-gnu-gcc

I would expect to see:

Using compiler .. /usr/bin/armv7a-hardfloat-linux-gnueabi-gcc

I think you may be mixing up the meaning HOST and TARGET a bit. TARGET is only used when building a cross-compiler; it is ignored when cross-compiling an application.
Comment 19 William Hubbs gentoo-dev 2014-03-24 17:23:39 UTC
One thing I think I would change is the order in which you search for
compilers.  On line 260, when you set the _COMPILERS variable, it might
be better to put cc last so you can look for the other compilers first.

You might also consider putting gcc before clang in that list since gcc
is a bit more common, but I think putting cc last is probably more
important.

Thoughts?

William
Comment 20 Roy Marples 2014-03-24 17:58:29 UTC
I have nfc why I did this anyway, I just use the host thingy to work out which source files I need - linux / bsd / kfreebsd
Comment 22 Roy Marples 2014-03-24 18:44:54 UTC
(In reply to William Hubbs from comment #19)
> One thing I think I would change is the order in which you search for
> compilers.  On line 260, when you set the _COMPILERS variable, it might
> be better to put cc last so you can look for the other compilers first.
> 
> You might also consider putting gcc before clang in that list since gcc
> is a bit more common, but I think putting cc last is probably more
> important.
> 
> Thoughts?

cc is supposed to be the user selected compiler.
So we're going to play "pick the compiler based on --host" then cc will be first, then a list of real compilers.
Comment 23 Mike Gilbert gentoo-dev 2014-03-24 19:01:58 UTC
(In reply to Roy Marples from comment #21)
> Better?

That works quite well. Thanks!
Comment 24 William Hubbs gentoo-dev 2014-03-24 19:18:29 UTC
Roy,

should I cherry-pick all of these patches, or are you going to release 6.3.3 soon?

Thanks,

William
Comment 25 Roy Marples 2014-03-24 19:41:13 UTC
You're already forcing $CC so no real need to cherry pick. But I should be releasing a  new version soon.
Comment 26 William Hubbs gentoo-dev 2014-03-24 20:10:34 UTC
Roy,

yes, $CC  is being forced in 6.3.2, but I was asking because I want to
change our package to use the upstream  fix and stop forcing $cc.

If you  are going to release in the nesxt  few days I'll wait for that,
but if not, I want to cherry-pick and do a revbump.

Thanks,

William
Comment 27 Mike Gilbert gentoo-dev 2014-03-24 22:05:47 UTC
(In reply to William Hubbs from comment #26)

Calling "tc-export CC" as the ebuild currently does resolves the issue. There is absolutely no reason to cherry-pick these changes.
Comment 28 Mike Gilbert gentoo-dev 2014-03-24 22:08:42 UTC
Also, even if you do cherry-pick them, a revbump is unnecessary: this is a build-time issue, and we are not actually changing any of the installed files.
Comment 29 William Hubbs gentoo-dev 2014-04-20 23:23:28 UTC
I have added the patches to dhcpcd-6.3.2.