Skip to contentSkip to conversation

hostapd: fix build

PATCH New Baruch Siach 3 participants 7 messages Jul 4, 2011 – Jul 5, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hostapd: fix build

The --sysroot option is required in CFLAGS and LDFLAGS to avoid compile time and link time failures.

---
 package/hostapd/hostapd.mk |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
package/hostapd/hostapd.mk +2 -2
index f097e75..8ca091d 100644
@@ -71,8 +71,8 @@ endif
 define HOSTAPD_CONFIGURE_CMDS
 	cp $(@D)/$(HOSTAPD_SUBDIR)/defconfig $(HOSTAPD_CONFIG)
 	$(SED) "s/\/local//" $(@D)/$(HOSTAPD_SUBDIR)/Makefile
-	echo "CFLAGS += $(TARGET_CFLAGS)" >>$(HOSTAPD_CONFIG)
-	echo "LDFLAGS += $(TARGET_LDFLAGS)" >>$(HOSTAPD_CONFIG)
+	echo "CFLAGS += $(TARGET_CFLAGS) --sysroot=$(STAGING_DIR)" >>$(HOSTAPD_CONFIG)
+	echo "LDFLAGS += $(TARGET_LDFLAGS) --sysroot=$(STAGING_DIR)" >>$(HOSTAPD_CONFIG)
 	echo "CC = $(TARGET_CC)" >>$(HOSTAPD_CONFIG)
 # Drivers
 	$(SED) "s/^#CONFIG_DRIVER_WIRED/CONFIG_DRIVER_WIRED/" $(HOSTAPD_CONFIG)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 2/2 iw: fix build

The --sysroot option is required in CFLAGS and LDFLAGS to avoid compile time and link time failures.

---
 package/iw/iw.mk |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
package/iw/iw.mk +2 -2
index 0f5dd0e..4db47c5 100644
@@ -15,8 +15,8 @@ IW_MAKE_ENV = PKG_CONFIG_PATH="$(STAGING_DIR)/usr/lib/pkgconfig" \
 
 define IW_CONFIGURE_CMDS
 	echo "CC = $(TARGET_CC)" >$(IW_CONFIG)
-	echo "CFLAGS = $(TARGET_CFLAGS)" >>$(IW_CONFIG)
-	echo "LDFLAGS = $(TARGET_LDFLAGS)" >>$(IW_CONFIG)
+	echo "CFLAGS = $(TARGET_CFLAGS) --sysroot=$(STAGING_DIR)" >>$(IW_CONFIG)
+	echo "LDFLAGS = $(TARGET_LDFLAGS) --sysroot=$(STAGING_DIR)" >>$(IW_CONFIG)
 endef
 
 define IW_BUILD_CMDS
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 1/2 hostapd: fix build

In reply to Baruch Siach

Hello,

Le Mon, 4 Jul 2011 09:00:29 +0300,
Baruch Siach <[email protected]> a ?crit :

Quoted 2 lines

The --sysroot option is required in CFLAGS and LDFLAGS to avoid compile time and link time failures.

This should no longer be needed, as Buildroot 2011.05 has added a wrapper for external toolchains which avoids the need to pass an explicit --sysroot option.

Can you point to a specific Buildroot configuration that exhibits the problem ?

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

PATCH 1/2 hostapd: fix build

Hi Thomas,

Quoted 9 lines · Thomas Petazzoni

Le Mon, 4 Jul 2011 09:00:29 +0300,
Baruch Siach <[email protected]> a ?crit :

Quoted 2 lines

The --sysroot option is required in CFLAGS and LDFLAGS to avoid compile time and link time failures.

This should no longer be needed, as Buildroot 2011.05 has added a wrapper for external toolchains which avoids the need to pass an explicit --sysroot option.

Actually, I've reverted part of this change to solve other problem. In package/Makefile.in I set TARGET_CROSS=$(BR2_TOOLCHAIN_EXTERNAL_PATH)/bin/$(TOOLCHAIN_EXTERNAL_PREFIX)-. I'm using the CodeSourcery toolchain for a e500v2 target. Without this change I get the following error (from ethtool config.log):

configure:3723: /home/baruch/git/buildroot/output/host/usr/bin/powerpc-linux-gnu-cpp conftest.c conftest.c:1:0: error: E500 and FPRs not supported
configure:3723: $? = 1
configure: failed program was:

| /* confdefs.h */
| #define PACKAGE_NAME "ethtool"
| #define PACKAGE_TARNAME "ethtool"
| #define PACKAGE_VERSION "2.6.38"
| #define PACKAGE_STRING "ethtool 2.6.38"
| #define PACKAGE_BUGREPORT "Ben Hutchings <[email protected]>"
| #define PACKAGE_URL ""
| #define PACKAGE "ethtool"
| #define VERSION "2.6.38"
| /* end confdefs.h.  */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|            Syntax error

To solve this I need to pass -te500v2 to cpp. Is there a clean way to do so?

I should also note that I add -te500v2 to TARGET_LDFLAGS and TOOLCHAIN_EXTERNAL_CFLAGS in package/Makefile.in and toolchain/toolchain-external/ext-tool.mk, respectively. I can reproduce the errors I get when omitting these changes if it helps.

baruch

Quoted 2 lines

Can you point to a specific Buildroot configuration that exhibits the problem ?

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#4 lore raw

PATCH 1/2 hostapd: fix build

In reply to Thomas Petazzoni

Hi Thomas,

Quoted 8 lines · Thomas Petazzoni

Hello,

Le Mon, 4 Jul 2011 09:00:29 +0300,
Baruch Siach <[email protected]> a ?crit :

Quoted 2 lines

The --sysroot option is required in CFLAGS and LDFLAGS to avoid compile time and link time failures.

Quoted 6 lines

This should no longer be needed, as Buildroot 2011.05 has added a wrapper for external toolchains which avoids the need to pass an explicit --sysroot option.

Can you point to a specific Buildroot configuration that exhibits the problem ?

The CodeSourcery PowerPC toolchains require a special flag which selects the sysroot. in our case, the flag is "-e500v2" which takes the place of "-mcpu=8540 -mspe -mabi=spe -mhard-float -mfloat-gprs=double" in a regular BR toolchain. In either case, if these optimizations are not passed to the compiler(s) AND the linker, the code generated can be wrong because (as far as I understand it) the e500 has no generic float instruction support and breaks the generic PowerPC ABI spec.

There is currently no way to pass this to the wrapper at compile time. I submitted a couple of patches to allow this, though I'm not sure I did it properly as I simply submitted my diffs.

Matias

Quoted 13 lines

Regards,

Thomas

Signature · 8 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
#5 lore raw

PATCH 1/2 hostapd: fix build

Hi Matias,

Quoted 16 lines · Matias Garcia
Quoted 8 lines · Thomas Petazzoni

Hello,

Le Mon, 4 Jul 2011 09:00:29 +0300,
Baruch Siach <[email protected]> a ?crit :

Quoted 2 lines

The --sysroot option is required in CFLAGS and LDFLAGS to avoid compile time and link time failures.

Quoted 6 lines

This should no longer be needed, as Buildroot 2011.05 has added a wrapper for external toolchains which avoids the need to pass an explicit --sysroot option.

Can you point to a specific Buildroot configuration that exhibits the problem ?

Quoted 7 lines

The CodeSourcery PowerPC toolchains require a special flag which selects the sysroot. in our case, the flag is "-e500v2" which takes the place of "-mcpu=8540 -mspe -mabi=spe -mhard-float -mfloat-gprs=double" in a regular BR toolchain. In either case, if these optimizations are not passed to the compiler(s) AND the linker, the code generated can be wrong because (as far as I understand it) the e500 has no generic float instruction support and breaks the generic PowerPC ABI spec.

I've noticed that the pre-processor also needs this flag, which is "-te500v2", by the way.

Quoted 3 lines

There is currently no way to pass this to the wrapper at compile time. I submitted a couple of patches to allow this, though I'm not sure I did it properly as I simply submitted my diffs.

For reference, here is the ugly hack that I'm currently using. I'll try to make a proper patch that allows the user to add an arbitrary option to all of CFLAGS/LDFLAGS/CPPFLAGS.

baruch

commit cbf2807a52408903033e960cd76d9644154980de

Author: Baruch Siach <[email protected]>
Date:   Tue Jul 5 12:06:22 2011 +0300

Crude patch for fixing CodeSourcery e500v2 builds

package/Makefile.in +2 -0
index 31a9639..45c3fce 100644
@@ -76,6 +76,7 @@ ifeq ($(BR2_LARGEFILE),y)
 TARGET_CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 endif
 
+TARGET_LDFLAGS+=-te500v2
 TARGET_CXXFLAGS=$(TARGET_CFLAGS)
 
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
@@ -173,6 +174,7 @@ TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
 		DEFAULT_ASSEMBLER="$(TARGET_AS)" \
 		DEFAULT_LINKER="$(TARGET_LD)" \
 		CFLAGS="$(TARGET_CFLAGS)" \
+		CPPFLAGS="-te500v2" \
 		CXXFLAGS="$(TARGET_CXXFLAGS)" \
 		LDFLAGS="$(TARGET_LDFLAGS)" \
 		FCFLAGS="$(TARGET_FCFLAGS)" \
toolchain/toolchain-external/ext-tool.mk +2 -0
index 9171e85..ffb8e22 100644
@@ -151,6 +151,8 @@ TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
 endif
 
+TOOLCHAIN_EXTERNAL_CFLAGS += -te500v2
+
 ifeq ($(BR2_VFP_FLOAT),y)
 TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=vfp
 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_VFPFLOAT=1

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#6 lore raw

PATCH 1/2 hostapd: fix build

Quoted 27 lines · Baruch Siach

Hi Matias,

Quoted 16 lines · Matias Garcia
Quoted 8 lines · Thomas Petazzoni

Hello,

Le Mon, 4 Jul 2011 09:00:29 +0300,
Baruch Siach <[email protected]> a ?crit :

Quoted 2 lines

The --sysroot option is required in CFLAGS and LDFLAGS to avoid compile time and link time failures.

Quoted 6 lines

This should no longer be needed, as Buildroot 2011.05 has added a wrapper for external toolchains which avoids the need to pass an explicit --sysroot option.

Can you point to a specific Buildroot configuration that exhibits the problem ?

Quoted 7 lines

The CodeSourcery PowerPC toolchains require a special flag which selects the sysroot. in our case, the flag is "-e500v2" which takes the place of "-mcpu=8540 -mspe -mabi=spe -mhard-float -mfloat-gprs=double" in a regular BR toolchain. In either case, if these optimizations are not passed to the compiler(s) AND the linker, the code generated can be wrong because (as far as I understand it) the e500 has no generic float instruction support and breaks the generic PowerPC ABI spec.

Quoted 2 lines

I've noticed that the pre-processor also needs this flag, which is "-te500v2", by the way.

That's interesting. When I use the wrapper, I don't need to supply the flag to anything else, as the wrapper adds it when powerpc-linux-gnu-[cpp|...] is called. Thanks for pointing out my typo.

Quoted 7 lines
Quoted 3 lines

There is currently no way to pass this to the wrapper at compile time. I submitted a couple of patches to allow this, though I'm not sure I did it properly as I simply submitted my diffs.

For reference, here is the ugly hack that I'm currently using. I'll try to make a proper patch that allows the user to add an arbitrary option to all of CFLAGS/LDFLAGS/CPPFLAGS.

My patch v1 added a new option to supply a sysroot argument to the wrapper, and v2 simply passed BR2_TARGET_OPTIMIZATIONS instead.

You are not actually passing TOOLCHAIN_EXTERNAL_CFLAGS to the wrapper which is why you need to add -te500v2 to your flags. TOOLCHAIN_EXTERNAL_CFLAGS helps buildroot determine which sysroot to use (i.e. which directory to specify in --sysroot), but it doesn't actually pass the flag to the wrapper. If the flag is not found in this array in ext-toolchain-wrapper.c, it is not getting compiled in:

static char *predef_args[] = {
	path,
	"--sysroot", BR_SYSROOT,
#ifdef BR_ARCH
	"-march=" BR_ARCH,
#endif /* BR_ARCH */
#ifdef BR_TUNE
	"-mtune=" BR_TUNE,
#endif /* BR_TUNE */
#ifdef BR_ABI
	"-mabi=" BR_ABI,
#endif
#ifdef BR_SOFTFLOAT
	"-msoft-float",
#endif /* BR_SOFTFLOAT */
#ifdef BR_VFPFLOAT
	"-mfpu=vfp",

#endif /* BR_VFPFLOAT */
};

Add the following code after "--sysroot",... and it will work without adding -te500v2 to CFLAGS/CPPFLAGS/LDFLAGS:

	"-te500v2",

Matias

Quoted 42 lines

baruch

commit cbf2807a52408903033e960cd76d9644154980de

Author: Baruch Siach <[email protected]>
Date:   Tue Jul 5 12:06:22 2011 +0300

Crude patch for fixing CodeSourcery e500v2 builds

package/Makefile.in +2 -0
index 31a9639..45c3fce 100644
@@ -76,6 +76,7 @@ ifeq ($(BR2_LARGEFILE),y)
 TARGET_CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 endif
 
+TARGET_LDFLAGS+=-te500v2
 TARGET_CXXFLAGS=$(TARGET_CFLAGS)
 
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
@@ -173,6 +174,7 @@ TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
 		DEFAULT_ASSEMBLER="$(TARGET_AS)" \
 		DEFAULT_LINKER="$(TARGET_LD)" \
 		CFLAGS="$(TARGET_CFLAGS)" \
+		CPPFLAGS="-te500v2" \
 		CXXFLAGS="$(TARGET_CXXFLAGS)" \
 		LDFLAGS="$(TARGET_LDFLAGS)" \
 		FCFLAGS="$(TARGET_FCFLAGS)" \
toolchain/toolchain-external/ext-tool.mk +2 -0
index 9171e85..ffb8e22 100644
@@ -151,6 +151,8 @@ TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
 endif
 
+TOOLCHAIN_EXTERNAL_CFLAGS += -te500v2
+
 ifeq ($(BR2_VFP_FLOAT),y)
 TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=vfp
 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_VFPFLOAT=1
Quoted 2 lines

baruch

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20110705/4a629cfc/attachment-0001.html>