Skip to contentSkip to conversation

Inheriting CFLAGS

DISCUSSION Jerome Brown 5 participants 13 messages Nov 15, 2004 – Nov 17, 2004

lore
Share & tools
lore
#0 lore raw

I am attempting to install Xen-2.0 using the Gentoo Ebuilds written by Philip Taylor, and have run into the same problem as A Streecar Named with needing to implement the -nopie flag.

As part of the Portage system, Gentoo users are able to specify their CFLAGS in a file which is exported to the environment in which the program is configured, built and installed.

Is it possible to have Xen inherit these CFLAGS as a base, and then modify them as required? Part of the enthusiasm over Gentoo is the ability to customise and optimise the applications.

Thanks in advance

Jerome

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#1 lore raw
Quoted 3 lines

I am attempting to install Xen-2.0 using the Gentoo Ebuilds written by Philip Taylor, and have run into the same problem as A Streecar Named with needing to implement the -nopie flag.

strange, I didn't have to do it (using ebuilds from
http://bugs.gentoo.org/show_bug.cgi?id=70161)

Quoted 7 lines

As part of the Portage system, Gentoo users are able to specify their CFLAGS in a file which is exported to the environment in which the program is configured, built and installed.

Is it possible to have Xen inherit these CFLAGS as a base, and then modify them as required? Part of the enthusiasm over Gentoo is the ability to customise and optimise the applications.

If you're talking about kernel, I don't think it's a good idea. None of the packages under sys-kernel inherits CFLAGS from Portage's /etc/make.conf.

j.

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#2 lore raw
Quoted 6 lines
Quoted 3 lines

I am attempting to install Xen-2.0 using the Gentoo Ebuilds written by Philip Taylor, and have run into the same problem as A Streecar Named with needing to implement the -nopie flag.

strange, I didn't have to do it (using ebuilds from
http://bugs.gentoo.org/show_bug.cgi?id=70161)

Yes, I did wonder about this.

Can you take a look in xen/arch/x86/Rules.mk and see if you have the lines:
# Disable PIE/SSP if GCC supports them. They can break us.

 CFLAGS  += $(call test-gcc-flag,-nopie)
 CFLAGS  += $(call test-gcc-flag,-fno-stack-protector)
 CFLAGS  += $(call test-gcc-flag,-fno-stack-protector-all)

If so then you have a *very* up-to-date tree. :-) I recently checked in a build fix that would disable PIE/SSP iff they are supported by GCC.

If not then I'm confused!

Quoted 7 lines
Quoted 3 lines

Is it possible to have Xen inherit these CFLAGS as a base, and then modify them as required? Part of the enthusiasm over Gentoo is the ability to customise and optimise the applications.

If you're talking about kernel, I don't think it's a good idea. None of the packages under sys-kernel inherits CFLAGS from Portage's /etc/make.conf.

Yeah, it's a bad idea! Kernels are very sensitive to compile flags -- both Xen and Linux use a wide range of GCC features and frequently use inline assembler, so the code is fragile when flags are changed from what we developers use. Allowing CFLAGS to be modified would be giving users a loaded gun. :-)

-- Keir

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#3 lore raw

No, I do not have those lines in my Rules.mk file. It was downloaded this morning using the ebuild, so was the xen-2.0.tgz file from sourceforge. If I add -nopie to the CFLAGS in Rules.mk file xen will compile fine, however if I add -nopie to my environment CFLAGS it does not get picked up by the xen build script. Therefore I can compile and install it, but it takes manual intervention, which defeats the idea of using an ebuild :)

I am not looking of inheriting CFLAGS into the kernel build process - I agree that it is bad. However I am unable to build Xen-2.0 itself with my compiler. Unfortunately, unlike with GCC 3.4, it doesn't compile a non-SSP/PIE version of gcc to use. (I'm running gcc 3.3.4)

Quoted 39 lines · Keir Fraser
Quoted 5 lines
Quoted 3 lines

I am attempting to install Xen-2.0 using the Gentoo Ebuilds written by Philip Taylor, and have run into the same problem as A Streecar Named with needing to implement the -nopie flag.

strange, I didn't have to do it (using ebuilds from http://bugs.gentoo.org/show_bug.cgi?id=70161)

Yes, I did wonder about this.

Can you take a look in xen/arch/x86/Rules.mk and see if you have the lines:
# Disable PIE/SSP if GCC supports them. They can break us.

 CFLAGS  += $(call test-gcc-flag,-nopie)
 CFLAGS  += $(call test-gcc-flag,-fno-stack-protector)
 CFLAGS  += $(call test-gcc-flag,-fno-stack-protector-all)

If so then you have a *very* up-to-date tree. :-) I recently checked in a build fix that would disable PIE/SSP iff they are supported by GCC.

If not then I'm confused!

Quoted 5 lines
Quoted 3 lines

Is it possible to have Xen inherit these CFLAGS as a base, and then modify them as required? Part of the enthusiasm over Gentoo is the ability to customise and optimise the applications.

If you're talking about kernel, I don't think it's a good idea. None of the packages under sys-kernel inherits CFLAGS from Portage's /etc/make.conf.

Yeah, it's a bad idea! Kernels are very sensitive to compile flags -- both Xen and Linux use a wide range of GCC features and frequently use inline assembler, so the code is fragile when flags are changed from what we developers use. Allowing CFLAGS to be modified would be giving users a loaded gun. :-)

-- Keir

Quoted 11 lines

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xen-devel

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#4 lore raw

Jerome Brown wrote on 15/11/2004 23:19:

Quoted 1 line

No, I do not have those lines in my Rules.mk file. It was downloaded this morning using the ebuild, so was the xen-2.0.tgz file from sourceforge. If I add -nopie to the CFLAGS in Rules.mk file xen will compile fine, however if I add -nopie to my environment CFLAGS it does not get picked up by the xen build script. Therefore I can compile and install it, but it takes manual intervention, which defeats the idea of using an ebuild :)

Have you tried it with the updated ebuild (by SpanKY) at http://bugs.gentoo.org/attachment.cgi?id=43893 ? I'm not completely sure what it actually does, but it looks a bit like it alters CFLAGS in Rules.mk and a few other Makefiles to pick up the environment's CFLAGS:

	sed -i \
		-e "/CFLAGS/s:-O3:${CFLAGS}:" \
		tools/libx{c,util}/Makefile \
		tools/misc/{miniterm,nsplitd}/Makefile \
		tools/{misc,xentrace}/Makefile \
		xen/arch/x86/Rules.mk || die "sed cflags"
Signature · 9 lines
Philip Taylor
[email protected]


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
#5 lore raw

Thats solves the problem (I can tell just looking at it!)

To the xen-devels - is this a fair way to go about it (manually editing the Rules.mk to import CFLAGS) or is there a better way to go about it?

Cheers

Jerome

Quoted 5 lines · Philip Taylor

Jerome Brown wrote on 15/11/2004 23:19:

Quoted 1 line

No, I do not have those lines in my Rules.mk file. It was downloaded this morning using the ebuild, so was the xen-2.0.tgz file from sourceforge. If I add -nopie to the CFLAGS in Rules.mk file xen will compile fine, however if I add -nopie to my environment CFLAGS it does not get picked up by the xen build script. Therefore I can compile and install it, but it takes manual intervention, which defeats the idea of using an ebuild :)

Quoted 8 lines

Have you tried it with the updated ebuild (by SpanKY) at http://bugs.gentoo.org/attachment.cgi?id=43893 ? I'm not completely sure what it actually does, but it looks a bit like it alters CFLAGS in Rules.mk and a few other Makefiles to pick up the environment's CFLAGS:

    sed -i \
        -e "/CFLAGS/s:-O3:${CFLAGS}:" \
        tools/libx{c,util}/Makefile \
        tools/misc/{miniterm,nsplitd}/Makefile \
        tools/{misc,xentrace}/Makefile \
        xen/arch/x86/Rules.mk || die "sed cflags"

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#6 lore raw
Quoted 5 lines

Thats solves the problem (I can tell just looking at it!)

To the xen-devels - is this a fair way to go about it (manually editing the Rules.mk to import CFLAGS) or is there a better way to go about it?

The unstable tree now includes Makefile fixes to work correctly with PIE/SSP-enabled GCC. No manual CFLAGS fixing will be required.

-- Keir

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#7 lore raw

Is there plans to create a patch that can be applied to the stable 2.0 tree to allow this?

Cheers

Jerome

Quoted 11 lines · Keir Fraser
Quoted 3 lines

Thats solves the problem (I can tell just looking at it!)

To the xen-devels - is this a fair way to go about it (manually editing the Rules.mk to import CFLAGS) or is there a better way to go about it?

The unstable tree now includes Makefile fixes to work correctly with PIE/SSP-enabled GCC. No manual CFLAGS fixing will be required.

-- Keir

Quoted 11 lines

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xen-devel

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#8 lore raw

I'll port it across to 2.0.

-- Keir

Quoted 33 lines

Is there plans to create a patch that can be applied to the stable 2.0 tree to allow this?

Cheers

Jerome

Quoted 12 lines · Keir Fraser
Quoted 4 lines

Thats solves the problem (I can tell just looking at it!)

To the xen-devels - is this a fair way to go about it (manually editing the Rules.mk to import CFLAGS) or is there a better way to go about it?

The unstable tree now includes Makefile fixes to work correctly with PIE/SSP-enabled GCC. No manual CFLAGS fixing will be required.

-- Keir

Quoted 11 lines

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xen-devel

Quoted 9 lines

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xen-devel

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#9 lore raw
In reply to Keir Fraser
Quoted 16 lines
Quoted 6 lines
Quoted 3 lines

I am attempting to install Xen-2.0 using the Gentoo Ebuilds written by Philip Taylor, and have run into the same problem as A Streecar Named with needing to implement the -nopie flag.

strange, I didn't have to do it (using ebuilds from
http://bugs.gentoo.org/show_bug.cgi?id=70161)

Yes, I did wonder about this.

Can you take a look in xen/arch/x86/Rules.mk and see if you have the lines:
# Disable PIE/SSP if GCC supports them. They can break us.

 CFLAGS  += $(call test-gcc-flag,-nopie)
 CFLAGS  += $(call test-gcc-flag,-fno-stack-protector)
 CFLAGS  += $(call test-gcc-flag,-fno-stack-protector-all)
Quoted 5 lines

If so then you have a *very* up-to-date tree. :-) I recently checked in a build fix that would disable PIE/SSP iff they are supported by GCC.

If not then I'm confused!

No, I can't seen anything like that.

zirafa ~ # gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/specs Configured with: /var/tmp/portage/gcc-3.3.4-r1/work/gcc-3.3.4/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++ --enable-threads=posix --enable-long-long --disable-checking --disable-libunwind-exceptions--enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --disable-multilib --enable-__cxa_atexit --enable-clocale=generic
Thread model: posix
gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6) zirafa ~ # ebuild /usr/local/portage/sys-apps/xen/xen-2.0.ebuild unpack zirafa ~ # cat /var/tmp/portage/xen-2.0/work/xen-2.0/xen/arch/x86/Rules.mk
########################################

# x86-specific definitions

CC := gcc
LD := ld

CFLAGS  := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
CFLAGS  += -iwithprefix include -Wall -Werror -pipe
CFLAGS  += -I$(BASEDIR)/include -Wno-pointer-arith -Wredundant-decls

ifeq ($(optimize),y)
CFLAGS += -O3 -march=pentium2 -pipe -fomit-frame-pointer else
x86_32/usercopy.o: CFLAGS += -O1
endif

# Prevent floating-point variables from creeping into Xen. CFLAGS += -msoft-float

ifeq ($(TARGET_SUBARCH),x86_32)
CFLAGS += -m32 -march=i686
LDFLAGS := --oformat elf32-i386
endif

ifeq ($(TARGET_SUBARCH),x86_64)
CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks CFLAGS += -fno-asynchronous-unwind-tables LDFLAGS := --oformat elf64-x86-64
endif

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#10 lore raw
Quoted 6 lines · Jan Kundrát
CFLAGS  := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
CFLAGS  += -iwithprefix include -Wall -Werror -pipe
CFLAGS  += -I$(BASEDIR)/include -Wno-pointer-arith -Wredundant-decls

ifeq ($(optimize),y)
CFLAGS += -O3 -march=pentium2 -pipe -fomit-frame-pointer

It looks like the ebuild changed the last line above to that (I assume your CFLAGS env variable is -O3 -march=pentium2 -pipe). I didn't use the ebuild, so I had the default line of CFLAGS += -O3 -fomit-frame-pointer, and found that I had to add -nopie and -fno-stack-protector to compile xen.

Perhaps -march=pentium2 fixed it for you? Or perhaps those were just somethings special I had to do on the crusoe?!?

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#11 lore raw

The modified ebuild on bugs.gentoo.org has a sed command to update the Rules.mk file to inherit the cflags that you set in make.conf

Is all go now (YAY!)

Jerome

Quoted 16 lines · A Streetcar Named
Quoted 6 lines · Jan Kundrát
CFLAGS  := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
CFLAGS  += -iwithprefix include -Wall -Werror -pipe
CFLAGS  += -I$(BASEDIR)/include -Wno-pointer-arith -Wredundant-decls

ifeq ($(optimize),y)
CFLAGS += -O3 -march=pentium2 -pipe -fomit-frame-pointer

It looks like the ebuild changed the last line above to that (I assume your CFLAGS env variable is -O3 -march=pentium2 -pipe). I didn't use the ebuild, so I had the default line of CFLAGS += -O3

(quoted diff) +0 -2
-fomit-frame-pointer, and found that I had to add -nopie and
-fno-stack-protector to compile xen.
Quoted 4 lines

Perhaps -march=pentium2 fixed it for you? Or perhaps those were just somethings special I had to do on the crusoe?!?

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#12 lore raw
In reply to A Streetcar Named

Review

Quoted 12 lines
Quoted 6 lines
CFLAGS  := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing
CFLAGS  += -iwithprefix include -Wall -Werror -pipe
CFLAGS  += -I$(BASEDIR)/include -Wno-pointer-arith -Wredundant-decls

ifeq ($(optimize),y)
CFLAGS += -O3 -march=pentium2 -pipe -fomit-frame-pointer

It looks like the ebuild changed the last line above to that (I assume your CFLAGS env variable is -O3 -march=pentium2 -pipe). I didn't use the ebuild, so I had the default line of CFLAGS += -O3

(quoted diff) +0 -2
-fomit-frame-pointer, and found that I had to add -nopie and
-fno-stack-protector to compile xen.

maybe, there's some sed stuff in the ebuild

Quoted 2 lines

Perhaps -march=pentium2 fixed it for you? Or perhaps those were just somethings special I had to do on the crusoe?!?

who knows ;-)

j.

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8