Message ID | 1364550643-11793-4-git-send-email-sonic.adi@gmail.com |
---|---|
State | Changes Requested |
Headers | show |
Dear Sonic Zhang, On Fri, 29 Mar 2013 17:50:40 +0800, Sonic Zhang wrote: > +# Set up flat binary type > +choice > + prompt "FLAT Binary type" > + depends on BR2_BINFMT_FLAT > + default BR2_BINFMT_FLAT_ONE > +config BR2_BINFMT_FLAT_ONE > + bool "One binary" > +config BR2_BINFMT_FLAT_SEP_DATA > + bool "Separate data and code" depends on BR2_bfin || BR2_m68k I know I've suggested on PATCH 3/7 to make FLAT depend on bfin, so technically this isn't needed. But since -msep-data is really an option that is only available on bfin and m68k, while the flat format can be used potentially on other architectures, I'd prefer to make this architecture dependency explicit here as well. > +config BR2_BINFMT_FLAT_SHARED > + bool "Shared binary" depends on BR2_bfin || BR2_m68k Same reason: -mid-shared-library is only available for Blackfin and m68k. > +endchoice I would have originally thought of putting those choices directly within the list of BR2_BINFMT_* (i.e have a list containing elf, fdpic, flat-one, flat-sep-data, flat-shared). But maybe it makes more sense the way you did, some I'm fine with that. Having some help text for each choice would be nice. Thanks! Thomas
Hi Thomas, On Mon, Apr 8, 2013 at 4:51 AM, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote: > Dear Sonic Zhang, > > On Fri, 29 Mar 2013 17:50:40 +0800, Sonic Zhang wrote: > >> +# Set up flat binary type >> +choice >> + prompt "FLAT Binary type" >> + depends on BR2_BINFMT_FLAT >> + default BR2_BINFMT_FLAT_ONE >> +config BR2_BINFMT_FLAT_ONE >> + bool "One binary" >> +config BR2_BINFMT_FLAT_SEP_DATA >> + bool "Separate data and code" > > depends on BR2_bfin || BR2_m68k > > I know I've suggested on PATCH 3/7 to make FLAT depend on bfin, so > technically this isn't needed. But since -msep-data is really an option > that is only available on bfin and m68k, while the flat format can be > used potentially on other architectures, I'd prefer to make this > architecture dependency explicit here as well. > >> +config BR2_BINFMT_FLAT_SHARED >> + bool "Shared binary" > > depends on BR2_bfin || BR2_m68k > > Same reason: -mid-shared-library is only available for Blackfin and > m68k. OK. > >> +endchoice > > I would have originally thought of putting those choices directly > within the list of BR2_BINFMT_* (i.e have a list containing elf, fdpic, > flat-one, flat-sep-data, flat-shared). But maybe it makes more sense > the way you did, some I'm fine with that. > > Having some help text for each choice would be nice. > OK. Regards, Sonic
Hi Thomas, Just figure out the compiling flags for BINFMT_FLAT_SHARED and BINFMT_FLAT_SEP can't be put into the toolchain wrapper, because these flags are for application only, they can't be used to build Linux kernel. -mid-shared-library -mshared-library-id=0 -msep-data So, I have to move them back to file package/Makefile.in . Regards, Sonic
Dear Sonic Zhang, On Fri, 12 Apr 2013 11:39:41 +0800, Sonic Zhang wrote: > Just figure out the compiling flags for BINFMT_FLAT_SHARED and > BINFMT_FLAT_SEP can't be put into the toolchain wrapper, because these > flags are for application only, they can't be used to build Linux > kernel. > > -mid-shared-library -mshared-library-id=0 > -msep-data > > So, I have to move them back to file package/Makefile.in . Hum, that is not really nice, because the idea of the external toolchain wrapper is to ensure that when the user will use output/host/usr/bin/<arch>-gcc, he will get binaries that are built for the same architecture/flags than the binaries built by Buildroot. That's more or less the whole idea of the external toolchain wrapper thing. One option is to have something like: ifeq ($(BR2_bfin),y) LINUX_MAKE_FLAGS = KBUILD_CFLAGS = "$(TARGET_CFLAGS) -mno-id-shared-library ..." endif Not sure exactly if that's the right solution or not. Peter, you're the one who did the external toolchain wrapper originally. Could you comment on this specific issue? Thanks! Thomas
Hi Thomas, On Sat, Apr 13, 2013 at 10:31 PM, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote: > Dear Sonic Zhang, > > On Fri, 12 Apr 2013 11:39:41 +0800, Sonic Zhang wrote: > >> Just figure out the compiling flags for BINFMT_FLAT_SHARED and >> BINFMT_FLAT_SEP can't be put into the toolchain wrapper, because these >> flags are for application only, they can't be used to build Linux >> kernel. >> >> -mid-shared-library -mshared-library-id=0 >> -msep-data >> >> So, I have to move them back to file package/Makefile.in . > > Hum, that is not really nice, because the idea of the external > toolchain wrapper is to ensure that when the user will use > output/host/usr/bin/<arch>-gcc, he will get binaries that are built for > the same architecture/flags than the binaries built by Buildroot. > That's more or less the whole idea of the external toolchain wrapper > thing. > > One option is to have something like: > > ifeq ($(BR2_bfin),y) > LINUX_MAKE_FLAGS = > KBUILD_CFLAGS = "$(TARGET_CFLAGS) -mno-id-shared-library ..." > endif > > Not sure exactly if that's the right solution or not. Peter, you're the > one who did the external toolchain wrapper originally. Could you > comment on this specific issue? > The LINUX_MAKE_FLAGS should not include the shared flat specific flags "-mno-id-shared-library ...". Your suggestion doesn't work when building Linux kernel. We need some ways to remove flags "-mno-id-shared-library ..." from the gcc wrapper for the shared flat binary format when building Linux kernel. My new patch is to append the shared flat flags only when building applications. Any better solution? Regards, Sonic
Dear Sonic Zhang, On Tue, 16 Apr 2013 18:26:22 +0800, Sonic Zhang wrote: > > Not sure exactly if that's the right solution or not. Peter, you're the > > one who did the external toolchain wrapper originally. Could you > > comment on this specific issue? > > > The LINUX_MAKE_FLAGS should not include the shared flat specific flags > "-mno-id-shared-library ...". Your suggestion doesn't work when > building Linux kernel. We need some ways to remove flags > "-mno-id-shared-library ..." from the gcc wrapper for the shared flat > binary format when building Linux kernel. Hm? If you pass -mno-id-shared-library after -mid-shared-library, it will be just as if you hadn't passed the option at all. So if the external toolchain wrapper passes -mid-shared-library, but then the CFLAGS passed to the kernel override that by passing -mno-id-shared-library, it will be just as if the external wrapper hadn't passed -mid-shared-library. Thomas
Hi Thomas, On Tue, Apr 16, 2013 at 6:46 PM, Thomas Petazzoni < thomas.petazzoni@free-electrons.com> wrote: > Dear Sonic Zhang, > > On Tue, 16 Apr 2013 18:26:22 +0800, Sonic Zhang wrote: > > > > Not sure exactly if that's the right solution or not. Peter, you're the > > > one who did the external toolchain wrapper originally. Could you > > > comment on this specific issue? > > > > > The LINUX_MAKE_FLAGS should not include the shared flat specific flags > > "-mno-id-shared-library ...". Your suggestion doesn't work when > > building Linux kernel. We need some ways to remove flags > > "-mno-id-shared-library ..." from the gcc wrapper for the shared flat > > binary format when building Linux kernel. > > Hm? If you pass -mno-id-shared-library after -mid-shared-library, it > will be just as if you hadn't passed the option at all. So if the > external toolchain wrapper passes -mid-shared-library, but then the > CFLAGS passed to the kernel override that by passing > -mno-id-shared-library, it will be just as if the external wrapper > hadn't passed -mid-shared-library. > > The blackfin GNU toolchain doesn't understand flag "-mno-shared-library-id", "-mno-shared-library-id=" and "-mno-shared-library-id=0". Flag "-mshared-library-id=0" set in wrapper can't be canceled by passing "-mno-shared-library-id" later in linux.mk. ifeq ($(BR2_bfin),y) LINUX_MAKE_FLAGS += KBUILD_CFLAGS="$(TARGET_CFLAGS) -mno-id-shared-library -mno-shared-library-id -mno-sep-data" endif PATH="/home/sonic/projects/buildroot/output/host/bin:/home/sonic/projects/buildroot/output/host/usr/bin:/home/sonic/projects/buildroot/output/host/usr/sbin/:/opt/arm/bin:/opt/uclinux/bfin-elf/bin/:/opt/uclinux/bfin-uclinux/bin/:/opt/uclinux/bfin-linux-uclibc/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" PERLLIB="/home/sonic/projects/buildroot/output/host/usr/lib/perl" /usr/bin/make -j4 O="/home/sonic/projects/buildroot/output/build/linux-custom" HOSTCC="/usr/bin/gcc" HOSTCFLAGS="" ARCH=blackfin INSTALL_MOD_PATH=/home/sonic/projects/buildroot/output/target CROSS_COMPILE=" /home/sonic/projects/buildroot/output/host/usr/bin/bfin-uclinux-" DEPMOD=/home/sonic/projects/buildroot/output/host/usr/sbin/depmod KBUILD_CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -pipe -Os -D__NOMMU__ -D__uClinux__ -mno-id-shared-library -mno-shared-library-id -mno-sep-data" -C "linux/linux-kernel"/ uImage make[1]: Entering directory `/home/sonic/projects/buildroot/linux/linux-kernel' GEN /home/sonic/projects/buildroot/output/build/linux-custom/Makefile CHK include/generated/uapi/linux/version.h CC scripts/mod/empty.o cc1: error: unrecognized command line option "-mno-shared-library-id" /home/sonic/projects/buildroot/linux/linux-kernel/scripts/mod/empty.c:1: error: -mshared-library-id= specified without -mid-shared-library make[4]: *** [scripts/mod/empty.o] Error 1 make[3]: *** [scripts/mod] Error 2 make[2]: *** [scripts] Error 2 Regards, Sonic
Hi Peter and Thomas, Any further suggestion on how can I push forward this patch? Compiler parameter -mno-xxx is not an option for blackfin specific flag id-shared-library=0. Regards, Sonic On Wed, Apr 17, 2013 at 5:02 PM, Sonic Zhang <sonic.adi@gmail.com> wrote: > Hi Thomas, > > > On Tue, Apr 16, 2013 at 6:46 PM, Thomas Petazzoni < > thomas.petazzoni@free-electrons.com> wrote: > >> Dear Sonic Zhang, >> >> On Tue, 16 Apr 2013 18:26:22 +0800, Sonic Zhang wrote: >> >> > > Not sure exactly if that's the right solution or not. Peter, you're >> the >> > > one who did the external toolchain wrapper originally. Could you >> > > comment on this specific issue? >> > > >> > The LINUX_MAKE_FLAGS should not include the shared flat specific flags >> > "-mno-id-shared-library ...". Your suggestion doesn't work when >> > building Linux kernel. We need some ways to remove flags >> > "-mno-id-shared-library ..." from the gcc wrapper for the shared flat >> > binary format when building Linux kernel. >> >> Hm? If you pass -mno-id-shared-library after -mid-shared-library, it >> will be just as if you hadn't passed the option at all. So if the >> external toolchain wrapper passes -mid-shared-library, but then the >> CFLAGS passed to the kernel override that by passing >> -mno-id-shared-library, it will be just as if the external wrapper >> hadn't passed -mid-shared-library. >> >> > The blackfin GNU toolchain doesn't understand flag > "-mno-shared-library-id", "-mno-shared-library-id=" and > "-mno-shared-library-id=0". Flag "-mshared-library-id=0" set in wrapper > can't be canceled by passing "-mno-shared-library-id" later in linux.mk. > > > ifeq ($(BR2_bfin),y) > LINUX_MAKE_FLAGS += KBUILD_CFLAGS="$(TARGET_CFLAGS) -mno-id-shared-library > -mno-shared-library-id -mno-sep-data" > endif > > > PATH="/home/sonic/projects/buildroot/output/host/bin:/home/sonic/projects/buildroot/output/host/usr/bin:/home/sonic/projects/buildroot/output/host/usr/sbin/:/opt/arm/bin:/opt/uclinux/bfin-elf/bin/:/opt/uclinux/bfin-uclinux/bin/:/opt/uclinux/bfin-linux-uclibc/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" > PERLLIB="/home/sonic/projects/buildroot/output/host/usr/lib/perl" > /usr/bin/make -j4 > O="/home/sonic/projects/buildroot/output/build/linux-custom" > HOSTCC="/usr/bin/gcc" HOSTCFLAGS="" ARCH=blackfin > INSTALL_MOD_PATH=/home/sonic/projects/buildroot/output/target > CROSS_COMPILE=" > /home/sonic/projects/buildroot/output/host/usr/bin/bfin-uclinux-" > DEPMOD=/home/sonic/projects/buildroot/output/host/usr/sbin/depmod > KBUILD_CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE > -D_FILE_OFFSET_BITS=64 -pipe -Os -D__NOMMU__ -D__uClinux__ > -mno-id-shared-library -mno-shared-library-id -mno-sep-data" -C > "linux/linux-kernel"/ uImage > make[1]: Entering directory > `/home/sonic/projects/buildroot/linux/linux-kernel' > GEN /home/sonic/projects/buildroot/output/build/linux-custom/Makefile > CHK include/generated/uapi/linux/version.h > CC scripts/mod/empty.o > cc1: error: unrecognized command line option "-mno-shared-library-id" > /home/sonic/projects/buildroot/linux/linux-kernel/scripts/mod/empty.c:1: > error: -mshared-library-id= specified without -mid-shared-library > make[4]: *** [scripts/mod/empty.o] Error 1 > make[3]: *** [scripts/mod] Error 2 > make[2]: *** [scripts] Error 2 > > > Regards, > > Sonic >
diff --git a/arch/Config.in b/arch/Config.in index be475c0..cf081a3 100644 --- a/arch/Config.in +++ b/arch/Config.in @@ -190,6 +190,19 @@ config BR2_BINFMT_FLAT select BR2_PREFER_STATIC_LIB endchoice +# Set up flat binary type +choice + prompt "FLAT Binary type" + depends on BR2_BINFMT_FLAT + default BR2_BINFMT_FLAT_ONE +config BR2_BINFMT_FLAT_ONE + bool "One binary" +config BR2_BINFMT_FLAT_SEP_DATA + bool "Separate data and code" +config BR2_BINFMT_FLAT_SHARED + bool "Shared binary" +endchoice + if BR2_arm || BR2_armeb source "arch/Config.in.arm" endif diff --git a/toolchain/toolchain-external/ext-tool.mk b/toolchain/toolchain-external/ext-tool.mk index 27fd296..0ca1307 100644 --- a/toolchain/toolchain-external/ext-tool.mk +++ b/toolchain/toolchain-external/ext-tool.mk @@ -168,6 +168,14 @@ ifeq ($(BR2_BINFMT_FLAT),y) TOOLCHAIN_EXTERNAL_CFLAGS += -Wl,-elf2flt TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_BINFMT_FLAT endif +ifeq ($(BR2_BINFMT_FLAT_SEP_DATA),y) +TOOLCHAIN_EXTERNAL_CFLAGS += -msep-data +TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_BINFMT_FLAT_SEP_DATA +endif +ifeq ($(BR2_BINFMT_FLAT_SHARED),y) +TOOLCHAIN_EXTERNAL_CFLAGS += -mid-shared-library -mshared-library-id=0 +TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_BINFMT_FLAT_SHARED +endif ifneq ($(BR2_TARGET_OPTIMIZATION),) TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION)) diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c index 9a2fc70..c0eb2db 100644 --- a/toolchain/toolchain-external/ext-toolchain-wrapper.c +++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c @@ -50,6 +50,12 @@ static char *predef_args[] = { #ifdef BR_BINFMT_FLAT "-Wl,-elf2flt", #endif +#ifdef BR_BINFMT_FLAT_SEP_DATA + "-msep-data", +#endif +#ifdef BR_BINFMT_FLAT_SHARED + "-mid-shared-library -mshared-library-id=0", +#endif #ifdef BR_ADDITIONAL_CFLAGS BR_ADDITIONAL_CFLAGS #endif