You are not logged in.

#1 2014-11-08 22:10:39

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

How can I export an env var so makechrootpkg uses color when building

A recent thread made me aware that setting the GCC_COLORS variable causes gcc to colorize output during compilation which is nice.  If I build with makechrootpkg from devtools, how can I have this variable exported so that the build script sees it when building?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2014-11-08 22:19:01

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: How can I export an env var so makechrootpkg uses color when building

Good question.

EDIT: off-topic

Last edited by parchedas (2014-11-08 22:31:28)

Offline

#3 2014-11-08 22:23:54

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,514
Website

Re: How can I export an env var so makechrootpkg uses color when building

I don't use makechrootpkg, but doesn't makepkg still parse makepkg.conf?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2014-11-08 22:38:53

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: How can I export an env var so makechrootpkg uses color when building

@Trilby - Yes, that's the ticket I think.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#5 2014-11-08 23:52:12

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: How can I export an env var so makechrootpkg uses color when building

Nope, the export within the makepkg.conf works outside of the chroot, but not within the chroot.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2014-11-08 23:56:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,514
Website

Re: How can I export an env var so makechrootpkg uses color when building

Don't export the variable, put the command line option into the FLAGS.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2014-11-09 00:01:44

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: How can I export an env var so makechrootpkg uses color when building

I could but why does it work outside of the chroot exporting it?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#8 2014-11-09 01:10:38

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: How can I export an env var so makechrootpkg uses color when building

I think it is because it uses some sudo in there which discards env variables.

As a test I added

Defaults env_keep += "PKGDEST"

to /etc/sudoers and that made it all the way through extra-x86_64-build->makechootpkg ...
so try adding GCC_COLORS, it's a bit hacky though IMO

Last edited by parchedas (2014-11-09 01:12:16)

Offline

#9 2014-11-09 10:25:07

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: How can I export an env var so makechrootpkg uses color when building

The easiest thing to do is just modify the CFLAGS in the chroot... I leave this it marked unsolved since my original question remains open.  Thanks to all who replied.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#10 2014-11-09 18:21:24

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: How can I export an env var so makechrootpkg uses color when building

Another option is, because makechrootpkg recalls itself with sudo anyway, to call it with sudo to start with while passing in env variable.
i.e., this works for setting the packager

sudo PACKAGER="My Name" makechrootpkg

so I assume it would work for any env variable.

Offline

#11 2014-11-09 19:59:29

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: How can I export an env var so makechrootpkg uses color when building

Even if you do get GCC_COLORS=anything into the environment, this is only the equivalent of adding -fdiagnostics-color=auto to your CFLAGS. I suspect the test implied by "auto" fails when we involve nspawn and so you still have no color. The correct thing to do in this specific case is to add -fdiagnostics-color=always to your chroot image's CFLAGS in /etc/makepkg.conf.

In the general case, you can pass environment through to makepkg from makechrootpkg by just appending it after the end of options delimiter, i.e.

$ makechrootpkg -r /build/extra-x86_64 -- GCC_COLORS=1

And this Just Works™ because of handling in makepkg

Last edited by falconindy (2014-11-10 04:18:55)

Offline

#12 2014-11-12 00:43:34

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: How can I export an env var so makechrootpkg uses color when building

falconindy wrote:

In the general case, you can pass environment through to makepkg from makechrootpkg by just appending it after the end of options delimiter, i.e.

$ makechrootpkg -r /build/extra-x86_64 -- GCC_COLORS=1

And this Just Works™ because of handling in makepkg

That would be great but that doesn't seem to be in pacman from [core], unless I'm doing something stupid?

EDIT: Nope, I'm not, that patch was added after the last release of pacman 17 months ago.

Last edited by parchedas (2014-11-12 01:01:39)

Offline

#13 2015-03-09 07:35:48

ntisithoj
Member
Registered: 2015-03-09
Posts: 11

Re: How can I export an env var so makechrootpkg uses color when building

hmmm...  i have the same question/problem.   

I made my root with the following.. 

mkarchroot -C /etc/pacman.conf -M /etc/makepkg.conf $CHROOT/root base-devel

which presumably means that makepkg will read the vars in the copy of /etc/makepkg.conf it makes... and I can confirm that the vars are correct.  But when it compiles is uses the default "march=x86_64" rather that the "march=sandybridge" that is in the choot makepkg.  I tried passing "--config /mymakepkg.conf" but that did't work either.  I then tried (after reading this) to pass the args on the command...

makechrootpkg  -r $CHROOT -- CFLAGS="-march=sandybridge -mtune=sandybridge -O3 -pipe" CXXFLAGS="-march=sandybridge -mtune=sandybridge -O3 -pipe"

and that did nothing either.

I have no idea where the chrooted makepkg is getting these defauls values from.

in addition, the output shows

g++ -c -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 .....

which is odd as is has  "-pipe -O2" in there twice.

The same makepkg.conf works fine outside of chroot.  Unfortuantely some apps absolutely will not compile unless in chroot (like Firefox)

Am I missing something obvious here? Or is there another way to make the chooted makepkg use the vars I want?

Thanks

p.s. I stand corrected.  Even outside the chroot the flags get changed back to teh defaults

heres the section I edited

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-unknown-linux-gnu"
CFLAGS="-march=sandybridge -mtune=sandybridge -O3 -pipe"
CXXFLAGS="-march=sandybridge -mtune=sandybridge -O3 -pipe"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
MAKEFLAGS="-j5"

The Makefile lines that is generated is ...

CFLAGS        = -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE $(DEFINES)
CXXFLAGS      = -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE $(DEFINES)

Sooo...  where is it getting these values from ?

FYI, other packages work just fine

gcc  -march=sandybridge -mtune=sandybridge -O3 -pipe  -Wl,-O1,--sort-common,--as-needed,-z,relro -o termidx termidx.o  -lncurses -lutil

Is it the case that SOME packages disregard the makepkg.conf?

Last edited by ntisithoj (2015-03-09 08:17:29)

Offline

Board footer

Powered by FluxBB