Skip to contentSkip to conversation

package: Makefile.in: Add target compilation flags for NOMMU architecture.

PATCH New Sonic Zhang 4 participants 21 messages Mar 22, 2013 – Mar 29, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

From: Sonic Zhang <[email protected]>

v2-changes:
- Use double-dollar to cite ($(2)_FLAT_STACKSIZE)

v1-changes:
- Add BR2_TARGET_ABI_FLAT option
- Add NOMMU compiling macro
- Add FLAT ABI specific link flags
- Add stack size to FLAT link flags if macro <PKG>_FLAT_STACKSIZE is defined.

---
 arch/Config.in           |    3 +++
 package/Makefile.in      |    8 ++++++++
 package/pkg-autotools.mk |    5 +++++
 package/pkg-generic.mk   |    5 +++++
 4 files changed, 21 insertions(+), 0 deletions(-)
arch/Config.in +3 -0
index 472b10c..120c67e 100644
@@ -174,6 +174,9 @@ config BR2_GCC_TARGET_ABI
 config BR2_GCC_TARGET_CPU
 	string
 
+config BR2_TARGET_ABI_FLAT
+	bool
+
 if BR2_arm || BR2_armeb
 source "arch/Config.in.arm"
 endif
package/Makefile.in +8 -0
index a8bf36b..acfd9c8 100644
@@ -103,6 +103,14 @@ TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET
 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+TARGET_LDFLAGS += -Wl,-elf2flt
+endif
+
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif
+
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
 TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
 else
package/pkg-autotools.mk +5 -0
index 890506b..09bdc7b 100644
@@ -82,6 +82,11 @@ $(2)_CLEAN_OPT			?= clean
 $(2)_UNINSTALL_STAGING_OPT	?= DESTDIR=$$(STAGING_DIR) uninstall
 $(2)_UNINSTALL_TARGET_OPT	?= DESTDIR=$$(TARGET_DIR)  uninstall
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_CONF_ENV			+= LDFLAGS="$(TARGET_LDFLAGS) -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)"
+ endif
+endif
 
 #
 # Configure step. Only define it if not already defined by the package
package/pkg-generic.mk +5 -0
index 57b0fd0..5ce32f9 100644
@@ -303,6 +303,11 @@ endif
 
 $(2)_REDISTRIBUTE		?= YES
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_FLAT_LDFLAGS = -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)
+ endif
+endif
 
 $(2)_DEPENDENCIES ?= $(filter-out $(1),$(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES))))
 
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

From: Sonic Zhang <[email protected]>

v3-changes:
- Put space around variable assignments.

v2-changes:
- Create arch makefile.

v1-changes:
- Create blackfin makefile.
- Add blackfin target ABI options.
- Add blackfin cpu options and shared library installation options.
- Add blackfin cpu revision options and mcpu link flags
- Add blackfin FLAT specific makefile flags.
- Add shared library installation options and makefile targets to install shared libraries into rootfs image.
- Copy extra blackfin toolchain FDPIC shared libraries to target fs

---
 Makefile              |    2 +
 arch/Config.in.bfin   |  117 +++++++++++++++++++++++++++++++++++++++++++++++++
 arch/Makefile.in      |    5 ++
 arch/Makefile.in.bfin |   50 +++++++++++++++++++++
 4 files changed, 174 insertions(+), 0 deletions(-)
 create mode 100644 arch/Makefile.in
 create mode 100644 arch/Makefile.in.bfin
Makefile +2 -0
index 7f0822f..c2f43a4 100644
@@ -329,6 +329,8 @@ ifneq ($(PACKAGE_OVERRIDE_FILE),)
 -include $(PACKAGE_OVERRIDE_FILE)
 endif
 
+include arch/Makefile.in
+
 include package/*/*.mk
 
 include boot/common.mk
arch/Config.in.bfin +117 -0

127 lines not on this page · raw message

arch/Makefile.in new file +5 -0
new file mode 100644
index 0000000..d791118
@@ -0,0 +1,5 @@
+# The architecture specific Makefile.in.$ARCH should be included only
+# when the arch macro is selected.
+ifeq ($(BR2_bfin),y)
+include arch/Makefile.in.bfin
+endif
arch/Makefile.in.bfin new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Dear Sonic Zhang,

Please add a commit log explaining all what you're doing. Your changes are quite architecture-specific and touch the core of Buildroot, but there are also not comments and no commit log.

Also your changelog should be below the --- and not before, otherwise it ends up in the commit log forever.

Makefile ifneq ($(PACKAGE_OVERRIDE_FILE),) · line 332

Quoted 9 lines · Sonic Zhang
Makefile +1 -0
index 7f0822f..c2f43a4 100644
@@ -329,6 +329,8 @@ ifneq ($(PACKAGE_OVERRIDE_FILE),)
 -include $(PACKAGE_OVERRIDE_FILE)
 endif
 
+include arch/Makefile.in

I must admit I am not entirely happy with having Blackfin-specific Makefiles, but it's true that we already have some architecture-specific crap in package/Makefile.in that we could more cleanly spread in arch/Makefile.in.<arch>.

Quoted 5 lines
arch/Config.in.bfin +0 -0
index 0b137ae..0750b86 100644

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 16

Quoted 10 lines
arch/Config.in.bfin +7 -0
@@ -7,10 +7,127 @@ config BR2_BFIN_FDPIC
 config BR2_BFIN_FLAT
 	bool "FLAT"
 	select BR2_PREFER_STATIC_LIB
+config BR2_BFIN_FLAT_SEP_DATA
+	bool "FLAT (Separate data)"
+	select BR2_PREFER_STATIC_LIB
+config BR2_BFIN_SHARED_FLAT
+	bool "Shared FLAT"
+	select BR2_PREFER_STATIC_LIB
+endchoice

I don't think we should have Blackfin-specific options. As I suggested in the review of PATCH 1/2, we should probably have global BR2_BINFMT_<foo> options.

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 83

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_TARGET_CPU_REVISION
+	string "Target CPU revision"

Help text needed.

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 86

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_BFIN_INSTALL_ELF_SHARED
+	depends on BR2_bfin && !BR2_BFIN_FDPIC

Confused: why in the FDPIC case you would not install the ELF shared libraries?

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 22

Quoted 2 lines
arch/Config.in.bfin +2 -0
+	bool "Install ELF shared libraries"
+	default y

Help text needed.

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 93

Quoted 4 lines
arch/Config.in.bfin +4 -0
+config BR2_BFIN_INSTALL_FLAT_SHARED
+	depends on BR2_bfin
+	bool "Install FLAT shared libraries" if !BR2_BFIN_SHARED_FLAT
+	default y

Help text needed.

Quoted 30 lines
arch/Config.in.bfin +25 -0
+
 config BR2_ARCH
 	default "bfin"
 
 config BR2_ENDIAN
         default "LITTLE"
+
+config BR2_GCC_TARGET_CPU
+	default bf606		if BR2_bf606
+	default bf607		if BR2_bf607
+	default bf608		if BR2_bf608
+	default bf609		if BR2_bf609
+	default bf512		if BR2_bf512
+	default bf514		if BR2_bf514
+	default bf516		if BR2_bf516
+	default bf518		if BR2_bf518
+	default bf522		if BR2_bf522
+	default bf523		if BR2_bf523
+	default bf524		if BR2_bf524
+	default bf525		if BR2_bf525
+	default bf526		if BR2_bf526
+	default bf527		if BR2_bf527
+	default bf531		if BR2_bf531
+	default bf532		if BR2_bf532
+	default bf533		if BR2_bf533
+	default bf534		if BR2_bf534
+	default bf536		if BR2_bf536
+	default bf537		if BR2_bf537
+	default bf538		if BR2_bf538
+	default bf539		if BR2_bf539

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 133

Quoted 10 lines
arch/Config.in.bfin +10 -0
+	default bf542		if BR2_bf542
+	default bf544		if BR2_bf544
+	default bf547		if BR2_bf547
+	default bf548		if BR2_bf548
+	default bf549		if BR2_bf549
+	default bf561		if BR2_bf561
+
+config BR2_TARGET_ABI_FLAT
+	default n		if BR2_BFIN_FDPIC
+	default y

To be refactored with the BR2_BINFMT_<foo> stuff.

arch/Makefile.in line 5

Quoted 11 lines
arch/Makefile.in new file +5 -0
new file mode 100644
index 0000000..d791118
@@ -0,0 +1,5 @@
+# The architecture specific Makefile.in.$ARCH should be included only
+# when the arch macro is selected.
+ifeq ($(BR2_bfin),y)
+include arch/Makefile.in.bfin
+endif

Ok.

arch/Makefile.in.bfin line 1

Quoted 7 lines
arch/Makefile.in.bfin new file +1 -0
new file mode 100644
index 0000000..e16532a
@@ -0,0 +1,50 @@
+TARGETS-y =

Isn't that dangerous if someone else is using TARGETS-y ?

arch/Makefile.in.bfin line 3

Quoted 2 lines
arch/Makefile.in.bfin new file +2 -0
+TARGETS-$(BR2_BFIN_INSTALL_ELF_SHARED) += romfs.shared.libs.elf
+TARGETS-$(BR2_BFIN_INSTALL_FLAT_SHARED) += romfs.shared.libs.flat

What's the relation with "romfs" ?

Also, we more or less name all our targets target-<something>, so it would be good to follow this convention. Also remember to update the TARGET_EXCEPTIONS variable in support/scripts/graph-depends when you add more of such custom targets.

arch/Makefile.in.bfin line 8

Quoted 5 lines
arch/Makefile.in.bfin new file +5 -0
+TARGETS += $(TARGETS-y)
+
+ifeq ($(BR2_BFIN_FDPIC),y)
+USR_LIB_EXTERNAL_LIBS += libgfortran.so libgomp.so libmudflap.so libmudflapth.so libobjc.so
+endif

This is totally unrelated to Blackfin, and therefore has no reason to be here and to depend on BR2_BFIN_FDPIC.

arch/Makefile.in.bfin line 10

Quoted 1 line
arch/Makefile.in.bfin new file +1 -0
+CROSS_COMPILE_SHARED_ELF ?= bfin-linux-uclibc-

No reason to be here. Please use $(TARGET_CC) and $(TARGET_READELF) below.

arch/Makefile.in.bfin line 19

Quoted 9 lines
arch/Makefile.in.bfin new file +9 -0
+romfs.shared.libs.elf:
+	set -e; \
+	t=`$(CROSS_COMPILE_SHARED_ELF)gcc $(CPUFLAGS) -print-file-name=libc.a`; \
+	t=`dirname $$t`/../..; \
+	for i in $$t/lib/*so*; do \
+		i=`readlink -f "$$i"`; \
+		soname=`$(CROSS_COMPILE_SHARED_ELF)readelf -d "$$i" | sed -n '/(SONAME)/s:.*[[]\(.*\)[]].*:\1:p'`; \
+		$(INSTALL) -D $$i $(TARGET_DIR)/lib/$$soname; \
+	done

Isn't this done already by the external toolchain logic? Some documentation/comments on what you're doing here would be good. I'm trying to understand if it's really Blackfin-specific, if it's specific to the usage of external toolchains or would apply to the internal toolchain backend as well, etc.

arch/Makefile.in.bfin line 21

Quoted 1 line
arch/Makefile.in.bfin new file +1 -0
+CROSS_COMPILE_SHARED_FLAT ?= bfin-uclinux-

TARGET_CC to be used below.

arch/Makefile.in.bfin line 34

Quoted 13 lines
arch/Makefile.in.bfin new file +13 -0
+romfs.shared.libs.flat:
+	set -e; \
+	t=`$(CROSS_COMPILE_SHARED_FLAT)gcc $(CPUFLAGS) -mid-shared-library -print-file-name=libc`; \
+	if [ -f $$t -a ! -h $$t ] ; then \
+		$(INSTALL) -D $$t $(TARGET_DIR)/lib/lib1.so; \
+	fi
+
+ifeq ($(BR2_TARGET_CPU_REVISION),)
+TARGET_CPU = -mcpu=$(BR2_GCC_TARGET_CPU)
+else
+TARGET_CPU = -mcpu=$(BR2_GCC_TARGET_CPU)-$(BR2_TARGET_CPU_REVISION)
+endif
+TARGET_CFLAGS += $(call qstrip,$(TARGET_CPU))

This will not work for the external toolchain wrapper logic. The external toolchain wrapper logic (in toolchain/toolchain-external/ext-tool.mk) takes the value of BR2_GCC_TARGET_CPU and encodes it as a -mcpu in the external toolchain wrapper. We want this to be part of the external toolchain wrapper instead of TARGET_CFLAGS so that people directly using the external toolchain from host/usr/bin/ go through the wrapper, and end up having the same mcpu/march/mtune options as the Buildroot build.

arch/Makefile.in.bfin line 38

Quoted 3 lines
arch/Makefile.in.bfin new file +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__uClinux__
+endif

Why do you have this one here in a Blackfin-specific area, and the -D__NOMMU__ in PATCH 1/2 in an architecture-generic area?

arch/Makefile.in.bfin line 50

Quoted 11 lines
arch/Makefile.in.bfin new file +11 -0
+ifeq ($(BR2_BFIN_FLAT_SEP_DATA),y)
+TARGET_LDFLAGS += -msep-data
+TARGET_CFLAGS += -msep-data
+TARGET_CXXFLAGS += -msep-data
+endif
+
+ifeq ($(BR2_BFIN_SHARED_FLAT), y)
+TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
+TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
+TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
+endif

I think those options are used to select which multilib variant to use in the toolchain. Therefore, they should be encoded into the external toolchain wrapper and not just passed in TARGET_LDFLAGS, TARGET_CFLAGS and TARGET_CXXFLAGS.

Best 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 v3 2/2 buildroot: target: Add Blackfin architecture support.

Hi Thomas,

Quoted 37 lines · Thomas Petazzoni

Dear Sonic Zhang,

Please add a commit log explaining all what you're doing. Your changes are quite architecture-specific and touch the core of Buildroot, but there are also not comments and no commit log.

Also your changelog should be below the --- and not before, otherwise it ends up in the commit log forever.

Makefile ifneq ($(PACKAGE_OVERRIDE_FILE),) · line 332

Quoted 9 lines · Sonic Zhang
Makefile +1 -0
index 7f0822f..c2f43a4 100644
@@ -329,6 +329,8 @@ ifneq ($(PACKAGE_OVERRIDE_FILE),)
 -include $(PACKAGE_OVERRIDE_FILE)
 endif
 
+include arch/Makefile.in

I must admit I am not entirely happy with having Blackfin-specific Makefiles, but it's true that we already have some architecture-specific crap in package/Makefile.in that we could more cleanly spread in arch/Makefile.in.<arch>.

Quoted 11 lines
arch/Config.in.bfin +3 -0
index 0b137ae..0750b86 100644
@@ -7,10 +7,127 @@ config BR2_BFIN_FDPIC
 config BR2_BFIN_FLAT
      bool "FLAT"
      select BR2_PREFER_STATIC_LIB
+config BR2_BFIN_FLAT_SEP_DATA
+     bool "FLAT (Separate data)"
+     select BR2_PREFER_STATIC_LIB
Quoted 9 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 16

Quoted 4 lines
arch/Config.in.bfin +4 -0
+config BR2_BFIN_SHARED_FLAT
+     bool "Shared FLAT"
+     select BR2_PREFER_STATIC_LIB
+endchoice

I don't think we should have Blackfin-specific options. As I suggested in the review of PATCH 1/2, we should probably have global BR2_BINFMT_<foo> options.

OK. I will move these macro to arch/Config.in

Quoted 5 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 83

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_TARGET_CPU_REVISION
+     string "Target CPU revision"

Help text needed.

OK.

Quoted 6 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 86

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_BFIN_INSTALL_ELF_SHARED
+     depends on BR2_bfin && !BR2_BFIN_FDPIC

Confused: why in the FDPIC case you would not install the ELF shared libraries?

Blackfin Linux kernel supports running both FDPIC and FLAT applications concurrently if the binary format specific libraries installed properly. This option allow developer to install FDPIC libraries into a buildroot rootfs image built with binary format macro other than BR2_BINFMT_FDPIC. It doesn't take effect if BR2_BINMAT_FDPIC is configured.

Quoted 5 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 22

Quoted 2 lines
arch/Config.in.bfin +2 -0
+     bool "Install ELF shared libraries"
+     default y

Help text needed.

OK.

Quoted 41 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 93

Quoted 4 lines
arch/Config.in.bfin +4 -0
+config BR2_BFIN_INSTALL_FLAT_SHARED
+     depends on BR2_bfin
+     bool "Install FLAT shared libraries" if !BR2_BFIN_SHARED_FLAT
+     default y

Help text needed.

Quoted 34 lines
arch/Config.in.bfin +29 -0
+
 config BR2_ARCH
      default "bfin"
 
 config BR2_ENDIAN
         default "LITTLE"
+
+config BR2_GCC_TARGET_CPU
+     default bf606           if BR2_bf606
+     default bf607           if BR2_bf607
+     default bf608           if BR2_bf608
+     default bf609           if BR2_bf609
+     default bf512           if BR2_bf512
+     default bf514           if BR2_bf514
+     default bf516           if BR2_bf516
+     default bf518           if BR2_bf518
+     default bf522           if BR2_bf522
+     default bf523           if BR2_bf523
+     default bf524           if BR2_bf524
+     default bf525           if BR2_bf525
+     default bf526           if BR2_bf526
+     default bf527           if BR2_bf527
+     default bf531           if BR2_bf531
+     default bf532           if BR2_bf532
+     default bf533           if BR2_bf533
+     default bf534           if BR2_bf534
+     default bf536           if BR2_bf536
+     default bf537           if BR2_bf537
+     default bf538           if BR2_bf538
+     default bf539           if BR2_bf539
+     default bf542           if BR2_bf542
+     default bf544           if BR2_bf544
+     default bf547           if BR2_bf547
+     default bf548           if BR2_bf548
Quoted 9 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 133

Quoted 6 lines
arch/Config.in.bfin +6 -0
+     default bf549           if BR2_bf549
+     default bf561           if BR2_bf561
+
+config BR2_TARGET_ABI_FLAT
+     default n               if BR2_BFIN_FDPIC
+     default y

To be refactored with the BR2_BINFMT_<foo> stuff.

OK.

Quoted 14 lines

arch/Makefile.in line 5

Quoted 11 lines
arch/Makefile.in new file +5 -0
new file mode 100644
index 0000000..d791118
@@ -0,0 +1,5 @@
+# The architecture specific Makefile.in.$ARCH should be included only
+# when the arch macro is selected.
+ifeq ($(BR2_bfin),y)
+include arch/Makefile.in.bfin
+endif

Ok.

Quoted 9 lines

arch/Makefile.in.bfin line 1

Quoted 7 lines
arch/Makefile.in.bfin new file +1 -0
new file mode 100644
index 0000000..e16532a
@@ -0,0 +1,50 @@
+TARGETS-y =

Isn't that dangerous if someone else is using TARGETS-y ?

Yes, this line can be removed.

Quoted 11 lines

arch/Makefile.in.bfin line 3

Quoted 3 lines
arch/Makefile.in.bfin new file +2 -0
+TARGETS-$(BR2_BFIN_INSTALL_ELF_SHARED) += romfs.shared.libs.elf
+TARGETS-$(BR2_BFIN_INSTALL_FLAT_SHARED) += romfs.shared.libs.flat

What's the relation with "romfs" ?

Also, we more or less name all our targets target-<something>, so it would be good to follow this convention. Also remember to update the TARGET_EXCEPTIONS variable in support/scripts/graph-depends when you add more of such custom targets.

OK.

Quoted 9 lines

arch/Makefile.in.bfin line 8

Quoted 5 lines
arch/Makefile.in.bfin new file +5 -0
+TARGETS += $(TARGETS-y)
+
+ifeq ($(BR2_BFIN_FDPIC),y)
+USR_LIB_EXTERNAL_LIBS += libgfortran.so libgomp.so libmudflap.so libmudflapth.so libobjc.so
+endif

This is totally unrelated to Blackfin, and therefore has no reason to be here and to depend on BR2_BFIN_FDPIC.

Where should I put these library names to ?

Quoted 4 lines

arch/Makefile.in.bfin line 10

Quoted 1 line
arch/Makefile.in.bfin new file +1 -0
+CROSS_COMPILE_SHARED_ELF ?= bfin-linux-uclibc-

No reason to be here. Please use $(TARGET_CC) and $(TARGET_READELF) below.

There are 2 individual Blackfin toolchain binaries for FDPIC and FLAT format. The prefix names are different. And as I explained ahead, the target is to install libraries of a different binary format with different toolchain prefix name in current $(TARGET_CC) and $(TARGET_READELF). So, this macro can not be removed.

Quoted 10 lines

arch/Makefile.in.bfin line 19

Quoted 9 lines
arch/Makefile.in.bfin new file +9 -0
+romfs.shared.libs.elf:
+     set -e; \
+     t=`$(CROSS_COMPILE_SHARED_ELF)gcc $(CPUFLAGS) -print-file-name=libc.a`; \
+     t=`dirname $$t`/../..; \
+     for i in $$t/lib/*so*; do \
+             i=`readlink -f "$$i"`; \
+             soname=`$(CROSS_COMPILE_SHARED_ELF)readelf -d "$$i" | sed -n '/(SONAME)/s:.*[[]\(.*\)[]].*:\1:p'`; \
+             $(INSTALL) -D $$i $(TARGET_DIR)/lib/$$soname; \
+     done
Quoted 6 lines

Isn't this done already by the external toolchain logic? Some documentation/comments on what you're doing here would be good. I'm trying to understand if it's really Blackfin-specific, if it's specific to the usage of external toolchains or would apply to the internal toolchain backend as well, etc.

No. Refer to my explanation ahead.

Quoted 4 lines

arch/Makefile.in.bfin line 21

Quoted 1 line
arch/Makefile.in.bfin new file +1 -0
+CROSS_COMPILE_SHARED_FLAT ?= bfin-uclinux-

TARGET_CC to be used below.

Ditto.

Quoted 14 lines

arch/Makefile.in.bfin line 34

Quoted 13 lines
arch/Makefile.in.bfin new file +13 -0
+romfs.shared.libs.flat:
+     set -e; \
+     t=`$(CROSS_COMPILE_SHARED_FLAT)gcc $(CPUFLAGS) -mid-shared-library -print-file-name=libc`; \
+     if [ -f $$t -a ! -h $$t ] ; then \
+             $(INSTALL) -D $$t $(TARGET_DIR)/lib/lib1.so; \
+     fi
+
+ifeq ($(BR2_TARGET_CPU_REVISION),)
+TARGET_CPU = -mcpu=$(BR2_GCC_TARGET_CPU)
+else
+TARGET_CPU = -mcpu=$(BR2_GCC_TARGET_CPU)-$(BR2_TARGET_CPU_REVISION)
+endif
+TARGET_CFLAGS += $(call qstrip,$(TARGET_CPU))
Quoted 9 lines

This will not work for the external toolchain wrapper logic. The external toolchain wrapper logic (in toolchain/toolchain-external/ext-tool.mk) takes the value of BR2_GCC_TARGET_CPU and encodes it as a -mcpu in the external toolchain wrapper. We want this to be part of the external toolchain wrapper instead of TARGET_CFLAGS so that people directly using the external toolchain from host/usr/bin/ go through the wrapper, and end up having the same mcpu/march/mtune options as the Buildroot build.

OK

Quoted 6 lines

arch/Makefile.in.bfin line 38

Quoted 3 lines
arch/Makefile.in.bfin new file +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__uClinux__
+endif

Why do you have this one here in a Blackfin-specific area, and the -D__NOMMU__ in PATCH 1/2 in an architecture-generic area?

This is a blackfin specific hack for old applications. Can be removed in patch for upstream.

Quoted 18 lines

arch/Makefile.in.bfin line 50

Quoted 12 lines
arch/Makefile.in.bfin new file +11 -0
+ifeq ($(BR2_BFIN_FLAT_SEP_DATA),y)
+TARGET_LDFLAGS += -msep-data
+TARGET_CFLAGS += -msep-data
+TARGET_CXXFLAGS += -msep-data
+endif
+
+ifeq ($(BR2_BFIN_SHARED_FLAT), y)
+TARGET_LDFLAGS += -mid-shared-library -mshared-library-id=0
+TARGET_CFLAGS += -mid-shared-library -mshared-library-id=0
+TARGET_CXXFLAGS += -mid-shared-library -mshared-library-id=0
+endif

I think those options are used to select which multilib variant to use in the toolchain. Therefore, they should be encoded into the external toolchain wrapper and not just passed in TARGET_LDFLAGS, TARGET_CFLAGS and TARGET_CXXFLAGS.

OK.

Regards,

Sonic

#4 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Hi Sonic,

Quoted 191 lines · Sonic Zhang

Hi Thomas,

Quoted 37 lines · Thomas Petazzoni

Dear Sonic Zhang,

Please add a commit log explaining all what you're doing. Your changes are quite architecture-specific and touch the core of Buildroot, but there are also not comments and no commit log.

Also your changelog should be below the --- and not before, otherwise it ends up in the commit log forever.

Makefile ifneq ($(PACKAGE_OVERRIDE_FILE),) · line 332

Quoted 9 lines · Sonic Zhang
Makefile +1 -0
index 7f0822f..c2f43a4 100644
@@ -329,6 +329,8 @@ ifneq ($(PACKAGE_OVERRIDE_FILE),)
 -include $(PACKAGE_OVERRIDE_FILE)
 endif
 
+include arch/Makefile.in

I must admit I am not entirely happy with having Blackfin-specific Makefiles, but it's true that we already have some architecture-specific crap in package/Makefile.in that we could more cleanly spread in arch/Makefile.in.<arch>.

Quoted 11 lines
arch/Config.in.bfin +3 -0
index 0b137ae..0750b86 100644
@@ -7,10 +7,127 @@ config BR2_BFIN_FDPIC
 config BR2_BFIN_FLAT
      bool "FLAT"
      select BR2_PREFER_STATIC_LIB
+config BR2_BFIN_FLAT_SEP_DATA
+     bool "FLAT (Separate data)"
+     select BR2_PREFER_STATIC_LIB
Quoted 9 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 16

Quoted 4 lines
arch/Config.in.bfin +4 -0
+config BR2_BFIN_SHARED_FLAT
+     bool "Shared FLAT"
+     select BR2_PREFER_STATIC_LIB
+endchoice

I don't think we should have Blackfin-specific options. As I suggested in the review of PATCH 1/2, we should probably have global BR2_BINFMT_<foo> options.

OK. I will move these macro to arch/Config.in

Quoted 5 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 83

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_TARGET_CPU_REVISION
+     string "Target CPU revision"

Help text needed.

OK.

Quoted 6 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 86

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_BFIN_INSTALL_ELF_SHARED
+     depends on BR2_bfin && !BR2_BFIN_FDPIC

Confused: why in the FDPIC case you would not install the ELF shared libraries?

Blackfin Linux kernel supports running both FDPIC and FLAT applications concurrently if the binary format specific libraries installed properly. This option allow developer to install FDPIC libraries into a buildroot rootfs image built with binary format macro other than BR2_BINFMT_FDPIC. It doesn't take effect if BR2_BINMAT_FDPIC is configured.

Quoted 5 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 22

Quoted 2 lines
arch/Config.in.bfin +2 -0
+     bool "Install ELF shared libraries"
+     default y

Help text needed.

OK.

Quoted 41 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 93

Quoted 4 lines
arch/Config.in.bfin +4 -0
+config BR2_BFIN_INSTALL_FLAT_SHARED
+     depends on BR2_bfin
+     bool "Install FLAT shared libraries" if !BR2_BFIN_SHARED_FLAT
+     default y

Help text needed.

Quoted 34 lines
arch/Config.in.bfin +29 -0
+
 config BR2_ARCH
      default "bfin"
 
 config BR2_ENDIAN
         default "LITTLE"
+
+config BR2_GCC_TARGET_CPU
+     default bf606           if BR2_bf606
+     default bf607           if BR2_bf607
+     default bf608           if BR2_bf608
+     default bf609           if BR2_bf609
+     default bf512           if BR2_bf512
+     default bf514           if BR2_bf514
+     default bf516           if BR2_bf516
+     default bf518           if BR2_bf518
+     default bf522           if BR2_bf522
+     default bf523           if BR2_bf523
+     default bf524           if BR2_bf524
+     default bf525           if BR2_bf525
+     default bf526           if BR2_bf526
+     default bf527           if BR2_bf527
+     default bf531           if BR2_bf531
+     default bf532           if BR2_bf532
+     default bf533           if BR2_bf533
+     default bf534           if BR2_bf534
+     default bf536           if BR2_bf536
+     default bf537           if BR2_bf537
+     default bf538           if BR2_bf538
+     default bf539           if BR2_bf539
+     default bf542           if BR2_bf542
+     default bf544           if BR2_bf544
+     default bf547           if BR2_bf547
+     default bf548           if BR2_bf548
Quoted 9 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 133

Quoted 6 lines
arch/Config.in.bfin +6 -0
+     default bf549           if BR2_bf549
+     default bf561           if BR2_bf561
+
+config BR2_TARGET_ABI_FLAT
+     default n               if BR2_BFIN_FDPIC
+     default y

To be refactored with the BR2_BINFMT_<foo> stuff.

OK.

Quoted 14 lines

arch/Makefile.in line 5

Quoted 11 lines
arch/Makefile.in new file +5 -0
new file mode 100644
index 0000000..d791118
@@ -0,0 +1,5 @@
+# The architecture specific Makefile.in.$ARCH should be included only
+# when the arch macro is selected.
+ifeq ($(BR2_bfin),y)
+include arch/Makefile.in.bfin
+endif

Ok.

Quoted 9 lines

arch/Makefile.in.bfin line 1

Quoted 7 lines
arch/Makefile.in.bfin new file +1 -0
new file mode 100644
index 0000000..e16532a
@@ -0,0 +1,50 @@
+TARGETS-y =

Isn't that dangerous if someone else is using TARGETS-y ?

Yes, this line can be removed.

Quoted 11 lines

arch/Makefile.in.bfin line 3

Quoted 3 lines
arch/Makefile.in.bfin new file +2 -0
+TARGETS-$(BR2_BFIN_INSTALL_ELF_SHARED) += romfs.shared.libs.elf
+TARGETS-$(BR2_BFIN_INSTALL_FLAT_SHARED) += romfs.shared.libs.flat

What's the relation with "romfs" ?

Also, we more or less name all our targets target-<something>, so it would be good to follow this convention. Also remember to update the TARGET_EXCEPTIONS variable in support/scripts/graph-depends when you add more of such custom targets.

OK.

Quoted 4 lines

arch/Makefile.in.bfin

Quoted 4 lines
arch/Makefile.in.bfin new file +4 -0
+TARGETS += $(TARGETS-y)
+
+ifeq ($(BR2_BFIN_FDPIC),y)
+USR_LIB_EXTERNAL_LIBS += libgfortran.so libgomp.so libmudflap.so

libmudflapth.so libobjc.so

Quoted 5 lines

arch/Makefile.in.bfin line 8

Quoted 1 line
arch/Makefile.in.bfin new file +1 -0
+endif

This is totally unrelated to Blackfin, and therefore has no reason to be here and to depend on BR2_BFIN_FDPIC.

Where should I put these library names to ?

Quoted 2 lines
Quoted 1 line
arch/Makefile.in.bfin new file +1 -0
+CROSS_COMPILE_SHARED_ELF ?= bfin-linux-uclibc-
Quoted 9 lines
Quoted 2 lines

No reason to be here. Please use $(TARGET_CC) and $(TARGET_READELF) below.

There are 2 individual Blackfin toolchain binaries for FDPIC and FLAT format. The prefix names are different. And as I explained ahead, the target is to install libraries of a different binary format with different toolchain prefix name in current $(TARGET_CC) and $(TARGET_READELF). So, this macro can not be removed.

Currently all compilations are using TARGET_CC and such, which expands to $(TARGET_CROSS)gcc.
TARGET_CROSS in turn is derived as:

ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y) TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)- else
TARGET_CROSS=$(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
endif

If you need to have different prefixes, isn't it possible to hook into one of these variables, instead of creating a new variable CROSS_COMPILE_SHARED_ELF/FLAT ?
Depending on the elf/flat choice, you would then for example set BR2_TOOLCHAIN_EXTERNAL_PREFIX (possible from kconfig directly) (but this would work only for external toolchains), or override TARGET_CROSS. With such a change, you can reuse TARGET_CC and TARGET_READELF.

Best regards,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20130325/9d257eae/attachment-0001.html>

#5 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Hi Thomas,

Quoted 217 lines · Thomas De Schampheleire

Hi Sonic,

Quoted 192 lines · Sonic Zhang

Hi Thomas,

Quoted 37 lines · Thomas Petazzoni

Dear Sonic Zhang,

Please add a commit log explaining all what you're doing. Your changes are quite architecture-specific and touch the core of Buildroot, but there are also not comments and no commit log.

Also your changelog should be below the --- and not before, otherwise it ends up in the commit log forever.

Makefile ifneq ($(PACKAGE_OVERRIDE_FILE),) · line 332

Quoted 9 lines · Sonic Zhang
Makefile +1 -0
index 7f0822f..c2f43a4 100644
@@ -329,6 +329,8 @@ ifneq ($(PACKAGE_OVERRIDE_FILE),)
 -include $(PACKAGE_OVERRIDE_FILE)
 endif
 
+include arch/Makefile.in

I must admit I am not entirely happy with having Blackfin-specific Makefiles, but it's true that we already have some architecture-specific crap in package/Makefile.in that we could more cleanly spread in arch/Makefile.in.<arch>.

Quoted 11 lines
arch/Config.in.bfin +3 -0
index 0b137ae..0750b86 100644
@@ -7,10 +7,127 @@ config BR2_BFIN_FDPIC
 config BR2_BFIN_FLAT
      bool "FLAT"
      select BR2_PREFER_STATIC_LIB
+config BR2_BFIN_FLAT_SEP_DATA
+     bool "FLAT (Separate data)"
+     select BR2_PREFER_STATIC_LIB
Quoted 9 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 16

Quoted 4 lines
arch/Config.in.bfin +4 -0
+config BR2_BFIN_SHARED_FLAT
+     bool "Shared FLAT"
+     select BR2_PREFER_STATIC_LIB
+endchoice

I don't think we should have Blackfin-specific options. As I suggested in the review of PATCH 1/2, we should probably have global BR2_BINFMT_<foo> options.

OK. I will move these macro to arch/Config.in

Quoted 5 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 83

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_TARGET_CPU_REVISION
+     string "Target CPU revision"

Help text needed.

OK.

Quoted 6 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 86

Quoted 2 lines
arch/Config.in.bfin +2 -0
+config BR2_BFIN_INSTALL_ELF_SHARED
+     depends on BR2_bfin && !BR2_BFIN_FDPIC

Confused: why in the FDPIC case you would not install the ELF shared libraries?

Blackfin Linux kernel supports running both FDPIC and FLAT applications concurrently if the binary format specific libraries installed properly. This option allow developer to install FDPIC libraries into a buildroot rootfs image built with binary format macro other than BR2_BINFMT_FDPIC. It doesn't take effect if BR2_BINMAT_FDPIC is configured.

Quoted 5 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 22

Quoted 2 lines
arch/Config.in.bfin +2 -0
+     bool "Install ELF shared libraries"
+     default y

Help text needed.

OK.

Quoted 41 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 93

Quoted 4 lines
arch/Config.in.bfin +4 -0
+config BR2_BFIN_INSTALL_FLAT_SHARED
+     depends on BR2_bfin
+     bool "Install FLAT shared libraries" if !BR2_BFIN_SHARED_FLAT
+     default y

Help text needed.

Quoted 34 lines
arch/Config.in.bfin +29 -0
+
 config BR2_ARCH
      default "bfin"
 
 config BR2_ENDIAN
         default "LITTLE"
+
+config BR2_GCC_TARGET_CPU
+     default bf606           if BR2_bf606
+     default bf607           if BR2_bf607
+     default bf608           if BR2_bf608
+     default bf609           if BR2_bf609
+     default bf512           if BR2_bf512
+     default bf514           if BR2_bf514
+     default bf516           if BR2_bf516
+     default bf518           if BR2_bf518
+     default bf522           if BR2_bf522
+     default bf523           if BR2_bf523
+     default bf524           if BR2_bf524
+     default bf525           if BR2_bf525
+     default bf526           if BR2_bf526
+     default bf527           if BR2_bf527
+     default bf531           if BR2_bf531
+     default bf532           if BR2_bf532
+     default bf533           if BR2_bf533
+     default bf534           if BR2_bf534
+     default bf536           if BR2_bf536
+     default bf537           if BR2_bf537
+     default bf538           if BR2_bf538
+     default bf539           if BR2_bf539
+     default bf542           if BR2_bf542
+     default bf544           if BR2_bf544
+     default bf547           if BR2_bf547
+     default bf548           if BR2_bf548
Quoted 9 lines

arch/Config.in.bfin config BR2_BFIN_FDPIC · line 133

Quoted 6 lines
arch/Config.in.bfin +6 -0
+     default bf549           if BR2_bf549
+     default bf561           if BR2_bf561
+
+config BR2_TARGET_ABI_FLAT
+     default n               if BR2_BFIN_FDPIC
+     default y

To be refactored with the BR2_BINFMT_<foo> stuff.

OK.

Quoted 14 lines

arch/Makefile.in line 5

Quoted 11 lines
arch/Makefile.in new file +5 -0
new file mode 100644
index 0000000..d791118
@@ -0,0 +1,5 @@
+# The architecture specific Makefile.in.$ARCH should be included only
+# when the arch macro is selected.
+ifeq ($(BR2_bfin),y)
+include arch/Makefile.in.bfin
+endif

Ok.

Quoted 9 lines

arch/Makefile.in.bfin line 1

Quoted 7 lines
arch/Makefile.in.bfin new file +1 -0
new file mode 100644
index 0000000..e16532a
@@ -0,0 +1,50 @@
+TARGETS-y =

Isn't that dangerous if someone else is using TARGETS-y ?

Yes, this line can be removed.

Quoted 11 lines

arch/Makefile.in.bfin line 3

Quoted 3 lines
arch/Makefile.in.bfin new file +2 -0
+TARGETS-$(BR2_BFIN_INSTALL_ELF_SHARED) += romfs.shared.libs.elf
+TARGETS-$(BR2_BFIN_INSTALL_FLAT_SHARED) += romfs.shared.libs.flat

What's the relation with "romfs" ?

Also, we more or less name all our targets target-<something>, so it would be good to follow this convention. Also remember to update the TARGET_EXCEPTIONS variable in support/scripts/graph-depends when you add more of such custom targets.

OK.

Quoted 10 lines
Quoted 6 lines
arch/Makefile.in.bfin new file +4 -0
+TARGETS += $(TARGETS-y)
+
+ifeq ($(BR2_BFIN_FDPIC),y)
+USR_LIB_EXTERNAL_LIBS += libgfortran.so libgomp.so libmudflap.so

libmudflapth.so libobjc.so
+endif

This is totally unrelated to Blackfin, and therefore has no reason to be here and to depend on BR2_BFIN_FDPIC.

Where should I put these library names to ?

Quoted 2 lines
Quoted 1 line

+CROSS_COMPILE_SHARED_ELF ?= bfin-linux-uclibc-

Quoted 8 lines
Quoted 2 lines

No reason to be here. Please use $(TARGET_CC) and $(TARGET_READELF) below.

There are 2 individual Blackfin toolchain binaries for FDPIC and FLAT format. The prefix names are different. And as I explained ahead, the target is to install libraries of a different binary format with different toolchain prefix name in current $(TARGET_CC) and $(TARGET_READELF). So, this macro can not be removed.

Currently all compilations are using TARGET_CC and such, which expands to $(TARGET_CROSS)gcc.
TARGET_CROSS in turn is derived as:

ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y) TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)- else
TARGET_CROSS=$(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
endif

Quoted 7 lines

If you need to have different prefixes, isn't it possible to hook into one of these variables, instead of creating a new variable CROSS_COMPILE_SHARED_ELF/FLAT ?
Depending on the elf/flat choice, you would then for example set BR2_TOOLCHAIN_EXTERNAL_PREFIX (possible from kconfig directly) (but this would work only for external toolchains), or override TARGET_CROSS. With such a change, you can reuse TARGET_CC and TARGET_READELF.

I do set BR2_TOOLCHAIN_EXTERNAL_PREFIX to bfin-uclinux via kconfig to build the complete packages in buildroot. Meanwhile, I would like to install FDPIC libraries as well from the bfin-linux-uclibc toolchain folder, which is different from the bfin-uclinux I set to BR2_TOOLCHAIN_EXTERNAL_PREFIX.

Blackfin toolchain bfin-linux-uclibc and bfin-uclinux are located in different path.

Regards,

Sonic

#6 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Dear Sonic Zhang,

Quoted 8 lines · Sonic Zhang
Quoted 7 lines

If you need to have different prefixes, isn't it possible to hook into one of these variables, instead of creating a new variable CROSS_COMPILE_SHARED_ELF/FLAT ?
Depending on the elf/flat choice, you would then for example set BR2_TOOLCHAIN_EXTERNAL_PREFIX (possible from kconfig directly) (but this would work only for external toolchains), or override TARGET_CROSS. With such a change, you can reuse TARGET_CC and TARGET_READELF.

Quoted 8 lines

I do set BR2_TOOLCHAIN_EXTERNAL_PREFIX to bfin-uclinux via kconfig to build the complete packages in buildroot. Meanwhile, I would like to install FDPIC libraries as well from the bfin-linux-uclibc toolchain folder, which is different from the bfin-uclinux I set to BR2_TOOLCHAIN_EXTERNAL_PREFIX.

Blackfin toolchain bfin-linux-uclibc and bfin-uclinux are located in different path.

But the current external toolchain logic in toolchain/toolchain-external/ext-tool.mk only extracts either the bfin-uclinux sysroot *or* the bfin-linux-uclibc sysroot, so you in practice don't have both at the same time, at least with the current Buildroot. So presumably this would also need to be changed, right?

Thanks,

Thomas

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

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Ho Thomas,

Quoted 18 lines · Thomas Petazzoni

Dear Sonic Zhang,

Quoted 14 lines · Sonic Zhang
Quoted 7 lines

If you need to have different prefixes, isn't it possible to hook into one of these variables, instead of creating a new variable CROSS_COMPILE_SHARED_ELF/FLAT ?
Depending on the elf/flat choice, you would then for example set BR2_TOOLCHAIN_EXTERNAL_PREFIX (possible from kconfig directly) (but this would work only for external toolchains), or override TARGET_CROSS. With such a change, you can reuse TARGET_CC and TARGET_READELF.

I do set BR2_TOOLCHAIN_EXTERNAL_PREFIX to bfin-uclinux via kconfig to build the complete packages in buildroot. Meanwhile, I would like to install FDPIC libraries as well from the bfin-linux-uclibc toolchain folder, which is different from the bfin-uclinux I set to BR2_TOOLCHAIN_EXTERNAL_PREFIX.

Quoted 8 lines
Quoted 2 lines

Blackfin toolchain bfin-linux-uclibc and bfin-uclinux are located in different path.

But the current external toolchain logic in toolchain/toolchain-external/ext-tool.mk only extracts either the bfin-uclinux sysroot *or* the bfin-linux-uclibc sysroot, so you in practice don't have both at the same time, at least with the current Buildroot. So presumably this would also need to be changed, right?

Yes, that's why the installation target copy library files from the original toolchain folder other than the sysroot.

Regards,

Sonic

#8 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Dear Sonic Zhang,

Quoted 8 lines · Sonic Zhang
Quoted 5 lines

But the current external toolchain logic in toolchain/toolchain-external/ext-tool.mk only extracts either the bfin-uclinux sysroot *or* the bfin-linux-uclibc sysroot, so you in practice don't have both at the same time, at least with the current Buildroot. So presumably this would also need to be changed, right?

Yes, that's why the installation target copy library files from the original toolchain folder other than the sysroot.

That doesn't work: when bfin-linux-uclibc is used, then the bfin-uclinux toolchain is *NOT* installed. Your current code makes the assumption that this toolchain is installed system-wide, but that's not what we want in a Buildroot context.

But ok, it's not an impossible problem: we can tune the external toolchain logic so that it installs both sysroot when the user wants both the FDPIC and FLAT stuff.

Best 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
#9 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

In reply to Sonic Zhang
Quoted 1 line · Sonic Zhang

From: Sonic Zhang <[email protected]>

[snip]

Hi Sonic,

Looks like you again choose a difficult patch set to try to upstream...

After reading all the comments in this thread, I propose to split up
the patch set as follows in order to get some progress on it.

1. Add blackfin CPU choice.
This patch adds a Target CPU configuration option and uses it to select a -m option for gcc.

2. Introduce target CPU revision.
Adds the possibility (in the general infrastructure, not blackfin-specific) to have a free-form CPU revision string and append it to the target CPU. Only Blackfin actually uses this option.

3. Introduce BINFMT_FLAT.
Just introduce the symbol and add options in blackfin to select it.

4. Introduce package-specific BINFMT_FLAT options. I.e. <PKG>_FLAT_STACKSIZE

5. Introduce blackfin-specific Makefile
Probably needs more work.

6. Introduce NOMMU symbol
Probably needs more work.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#10 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Dear Arnout Vandecappelle,

Quoted 9 lines · Arnout Vandecappelle

Looks like you again choose a difficult patch set to try to upstream...

After reading all the comments in this thread, I propose to split up
the patch set as follows in order to get some progress on it.

1. Add blackfin CPU choice.
This patch adds a Target CPU configuration option and uses it to select a -m option for gcc.

Quoted 7 lines

2. Introduce target CPU revision.
Adds the possibility (in the general infrastructure, not blackfin-specific) to have a free-form CPU revision string and append it to the target CPU. Only Blackfin actually uses this option.

3. Introduce BINFMT_FLAT.
Just introduce the symbol and add options in blackfin to select it.

I don't think we should introduce just BINFMT_FLAT, but also BINFMT_FDPIC (we already have a FDPIC symbol) and BINFMT_ELF, for completeness. So I would rephrase this item into "Introduce BINFMT_* symbols and refactor the existing usage to use BINFMT_FDPIC/BINFMT_ELF".

Quoted 8 lines

4. Introduce package-specific BINFMT_FLAT options. I.e. <PKG>_FLAT_STACKSIZE

5. Introduce blackfin-specific Makefile
Probably needs more work.

6. Introduce NOMMU symbol
Probably needs more work.

I fully agree with Arnout's proposal here. Let's do it step by step, so that we discuss one issue after the other, and gets things merged progressively.

Sonic, would you mind reworking your patch set to split it as Arnout is suggesting?

Best 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
#11 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Hi Thomas and Arnout,

Quoted 35 lines · Thomas Petazzoni

Dear Arnout Vandecappelle,

Quoted 9 lines · Arnout Vandecappelle

Looks like you again choose a difficult patch set to try to upstream...

After reading all the comments in this thread, I propose to split up
the patch set as follows in order to get some progress on it.

1. Add blackfin CPU choice.
This patch adds a Target CPU configuration option and uses it to select a -m option for gcc.

Quoted 7 lines

2. Introduce target CPU revision.
Adds the possibility (in the general infrastructure, not blackfin-specific) to have a free-form CPU revision string and append it to the target CPU. Only Blackfin actually uses this option.

3. Introduce BINFMT_FLAT.
Just introduce the symbol and add options in blackfin to select it.

I don't think we should introduce just BINFMT_FLAT, but also BINFMT_FDPIC (we already have a FDPIC symbol) and BINFMT_ELF, for completeness. So I would rephrase this item into "Introduce BINFMT_* symbols and refactor the existing usage to use BINFMT_FDPIC/BINFMT_ELF".

Quoted 8 lines

4. Introduce package-specific BINFMT_FLAT options. I.e. <PKG>_FLAT_STACKSIZE

5. Introduce blackfin-specific Makefile
Probably needs more work.

6. Introduce NOMMU symbol
Probably needs more work.

Quoted 7 lines

I fully agree with Arnout's proposal here. Let's do it step by step, so that we discuss one issue after the other, and gets things merged progressively.

Sonic, would you mind reworking your patch set to split it as Arnout is suggesting?

Could you comment on the reworked patch set?

Regards,

Sonic

#12 lore raw

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Dear Sonic Zhang,

Quoted 4 lines · Sonic Zhang
Quoted 2 lines

Sonic, would you mind reworking your patch set to split it as Arnout is suggesting?

Could you comment on the reworked patch set?

Yes, sure. I've already looked at it. It looks a lot better, but I (of course) still have some comments. Will try to send some review soon, but I'll be on vacation until next Wednesday, with very limited time to do any sort of coding/reviewing.

Thanks!

Thomas

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

PATCH v3 2/2 buildroot: target: Add Blackfin architecture support.

Hi Thomas,

Quoted 7 lines · Thomas Petazzoni

Dear Sonic Zhang,

Quoted 3 lines · Sonic Zhang
Quoted 2 lines

Sonic, would you mind reworking your patch set to split it as Arnout is suggesting?

Quoted 7 lines
Quoted 1 line

Could you comment on the reworked patch set?

Yes, sure. I've already looked at it. It looks a lot better, but I (of course) still have some comments. Will try to send some review soon, but I'll be on vacation until next Wednesday, with very limited time to do any sort of coding/reviewing.

I just sent out the v2 patch set to fix some typo error. Please comment on the v2 after you are back.

Regards,

Sonic

#14 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

In reply to Sonic Zhang

Dear Sonic Zhang,

Quoted 1 line · Sonic Zhang

From: Sonic Zhang <[email protected]>

Thanks for getting back to us with Blackfin-related changes!

arch/Config.in config BR2_GCC_TARGET_ABI · line 178

Quoted 2 lines
arch/Config.in +2 -0
+config BR2_TARGET_ABI_FLAT
+	bool

I don't think FLAT is an ABI, it's a binary format.

For example, on ARM, you can have ELF or FLAT binaries, that follow either the OABI or EABI. True, OABI is deprecated, but it still clearly points the fact that FLAT is *not* an ABI, but a binary format.

Therefore, I think we should introduce config options like:

config BR2_BINFMT_ELF
bool

config BR2_BINFMT_FDPIC
bool

config BR2_BINFMT_FLAT
bool

probably with a choice list or something.

Quoted 8 lines

if BR2_arm || BR2_armeb
source "arch/Config.in.arm"
endif

package/Makefile.in +0 -0
index a8bf36b..acfd9c8 100644

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 108

Quoted 6 lines
package/Makefile.in +3 -0
@@ -103,6 +103,14 @@ TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET
 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+TARGET_LDFLAGS += -Wl,-elf2flt
+endif

This will have to use some BR2_BINFMT_FLAT config option, as per the discussion above.

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 112

Quoted 3 lines
package/Makefile.in +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif

I'm still not entirely happy with that. This define is completely non-standard, I am not sure we want to have this at the global level. autotools-based packages should be fixed to check if fork() is available or not. For other packages, this special flag can be introduced on a per-package basis. But it's true that maybe a good number of packages will need that. Not sure here. What do others think?

Quoted 9 lines
package/Makefile.in +1 -0
+
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
 TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
 else
package/pkg-autotools.mk +0 -0
index 890506b..09bdc7b 100644

package/pkg-autotools.mk $(2)_CLEAN_OPT ?= clean · line 89

Quoted 8 lines
package/pkg-autotools.mk +5 -0
@@ -82,6 +82,11 @@ $(2)_CLEAN_OPT			?= clean
 $(2)_UNINSTALL_STAGING_OPT	?= DESTDIR=$$(STAGING_DIR) uninstall
 $(2)_UNINSTALL_TARGET_OPT	?= DESTDIR=$$(TARGET_DIR)  uninstall
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_CONF_ENV			+= LDFLAGS="$(TARGET_LDFLAGS) -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)"
+ endif
+endif

Ok. This needs an update in the documentation, detailing the new <pkg>_FLAT_STACKSIZE option.

Quoted 7 lines
package/pkg-autotools.mk +0 -0
 #
 # Configure step. Only define it if not already defined by the package
package/pkg-generic.mk +0 -0
index 57b0fd0..5ce32f9 100644

package/pkg-generic.mk endif · line 310

Quoted 8 lines
package/pkg-generic.mk +5 -0
@@ -303,6 +303,11 @@ endif
 
 $(2)_REDISTRIBUTE		?= YES
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_FLAT_LDFLAGS = -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)
+ endif
+endif

How is this one supposed to work? Who will use <pkg>_FLAT_LDFLAGS?

Best 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
#15 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

Hi,

Quoted 48 lines · Thomas Petazzoni

Dear Sonic Zhang,

Quoted 1 line · Sonic Zhang

From: Sonic Zhang <[email protected]>

Thanks for getting back to us with Blackfin-related changes!

arch/Config.in config BR2_GCC_TARGET_ABI · line 178

Quoted 2 lines
arch/Config.in +2 -0
+config BR2_TARGET_ABI_FLAT
+     bool

I don't think FLAT is an ABI, it's a binary format.

For example, on ARM, you can have ELF or FLAT binaries, that follow either the OABI or EABI. True, OABI is deprecated, but it still clearly points the fact that FLAT is *not* an ABI, but a binary format.

Therefore, I think we should introduce config options like:

config BR2_BINFMT_ELF
bool

config BR2_BINFMT_FDPIC
bool

config BR2_BINFMT_FLAT
bool

probably with a choice list or something.

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI)

Quoted 8 lines

if BR2_arm || BR2_armeb
source "arch/Config.in.arm"
endif

package/Makefile.in +0 -0
index a8bf36b..acfd9c8 100644
@@ -103,6 +103,14 @@ TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI)

$(TARGET_OPTIMIZATION) $(TARGET

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 108

Quoted 6 lines
package/Makefile.in +3 -0
 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+TARGET_LDFLAGS += -Wl,-elf2flt
+endif

This will have to use some BR2_BINFMT_FLAT config option, as per the discussion above.

Quoted 11 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 112

Quoted 3 lines
package/Makefile.in +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif

I'm still not entirely happy with that. This define is completely non-standard, I am not sure we want to have this at the global level. autotools-based packages should be fixed to check if fork() is available or not. For other packages, this special flag can be introduced on a per-package basis. But it's true that maybe a good number of packages will need that. Not sure here. What do others think?

Isn't this conceptually at the same level as settings like LARGEFILE, WCHAR, etc.
In the case of LARGEFILE, a variable DISABLE_LARGEFILE is provided (expanding to --disable-largefile), that packages can use to set the necessary config options in a common way. Package infrastructures like autotools-package can also use this.

This reasoning would then indeed suggest against such a global option, and instead only provide a way to set this flag on a per-package basis or in an infrastructure.

Best regards,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20130322/52fa0831/attachment.html>

#16 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

In reply to Thomas Petazzoni
Quoted 3 lines · Thomas Petazzoni

Dear Sonic Zhang,

On Fri, 22 Mar 2013 17:01:41 +0800, Sonic Zhang wrote:

[snip]

Quoted 10 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 112

Quoted 3 lines
package/Makefile.in +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif

I'm still not entirely happy with that. This define is completely non-standard, I am not sure we want to have this at the global level. autotools-based packages should be fixed to check if fork() is available or not. For other packages, this special flag can be introduced on a per-package basis. But it's true that maybe a good number of packages will need that. Not sure here. What do others think?

Since this is a non-standard flag, it would go together with some patch
that adds the possibility of NOMMU builds. I would say that it's a good idea to have an explicit extra -DNOMMU in those .mk files.

As to the large number of packages using it: it should anyway only be
used for make-based packages (autotools and cmake should have different ways to detect NOMMU). So the number of packages using it wouldn't be that large.

And finally, that do this that we have already (irda-utils and portmap)
call it NO_FORK.

Regards,
Arnout

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#17 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

In reply to Thomas Petazzoni

Hi Thomas,

Quoted 21 lines · Thomas Petazzoni

Dear Sonic Zhang,

Quoted 1 line · Sonic Zhang

From: Sonic Zhang <[email protected]>

Thanks for getting back to us with Blackfin-related changes!

arch/Config.in config BR2_GCC_TARGET_ABI · line 178

Quoted 2 lines
arch/Config.in +2 -0
+config BR2_TARGET_ABI_FLAT
+     bool

I don't think FLAT is an ABI, it's a binary format.

For example, on ARM, you can have ELF or FLAT binaries, that follow either the OABI or EABI. True, OABI is deprecated, but it still clearly points the fact that FLAT is *not* an ABI, but a binary format.

Therefore, I think we should introduce config options like:

config BR2_BINFMT_ELF
bool

Quoted 8 lines

config BR2_BINFMT_FDPIC
bool

config BR2_BINFMT_FLAT
bool

probably with a choice list or something.

OK.

Quoted 11 lines
Quoted 11 lines

if BR2_arm || BR2_armeb
source "arch/Config.in.arm"
endif

package/Makefile.in +0 -0
index a8bf36b..acfd9c8 100644
@@ -103,6 +103,14 @@ TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET
 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
 
Quoted 7 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 108

Quoted 3 lines
package/Makefile.in +3 -0
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+TARGET_LDFLAGS += -Wl,-elf2flt
+endif

This will have to use some BR2_BINFMT_FLAT config option, as per the discussion above.

OK.

Quoted 11 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 112

Quoted 3 lines
package/Makefile.in +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif

I'm still not entirely happy with that. This define is completely non-standard, I am not sure we want to have this at the global level. autotools-based packages should be fixed to check if fork() is available or not. For other packages, this special flag can be introduced on a per-package basis. But it's true that maybe a good number of packages will need that. Not sure here. What do others think?

Macro __NOMMU__ is not used only for fork/vfork. There are some difference between MMU and NOMMU application. For example:
- exit(n) should be replaced by _exit(n) in child process.
- Large buffer or array shouldn't be defined on stack.
- calloc() should be replaced by malloc().

All these changes to MMU application should be protected by macro __NOMMU__

Quoted 31 lines
Quoted 9 lines
package/Makefile.in +1 -0
+
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
 TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
 else
package/pkg-autotools.mk +0 -0
index 890506b..09bdc7b 100644

package/pkg-autotools.mk $(2)_CLEAN_OPT ?= clean · line 89

Quoted 8 lines
package/pkg-autotools.mk +5 -0
@@ -82,6 +82,11 @@ $(2)_CLEAN_OPT                     ?= clean
 $(2)_UNINSTALL_STAGING_OPT   ?= DESTDIR=$$(STAGING_DIR) uninstall
 $(2)_UNINSTALL_TARGET_OPT    ?= DESTDIR=$$(TARGET_DIR)  uninstall
 
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_CONF_ENV                      += LDFLAGS="$(TARGET_LDFLAGS) -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)"
+ endif
+endif

Ok. This needs an update in the documentation, detailing the new <pkg>_FLAT_STACKSIZE option.

Quoted 10 lines
package/pkg-autotools.mk +0 -0
 #
 # Configure step. Only define it if not already defined by the package
package/pkg-generic.mk +0 -0
index 57b0fd0..5ce32f9 100644
@@ -303,6 +303,11 @@ endif
 
 $(2)_REDISTRIBUTE            ?= YES
 
Quoted 7 lines

package/pkg-generic.mk endif · line 310

Quoted 5 lines
package/pkg-generic.mk +5 -0
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_FLAT_LDFLAGS = -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)
+ endif
+endif

How is this one supposed to work? Who will use <pkg>_FLAT_LDFLAGS?

If the generic package wants to be built into FLAT binary, it should append this package specific link flag <pkg>_FLAT_LDFLAGS to the build command line in its makefile. This flag can't be added to TARGET_LDFLAGS, because it is package specific.

Regards,

Sonic

#18 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

Quoted 69 lines · Sonic Zhang

Hi Thomas,

Quoted 21 lines · Thomas Petazzoni

Dear Sonic Zhang,

Quoted 1 line · Sonic Zhang

From: Sonic Zhang <[email protected]>

Thanks for getting back to us with Blackfin-related changes!

arch/Config.in config BR2_GCC_TARGET_ABI · line 178

Quoted 2 lines
arch/Config.in +2 -0
+config BR2_TARGET_ABI_FLAT
+     bool

I don't think FLAT is an ABI, it's a binary format.

For example, on ARM, you can have ELF or FLAT binaries, that follow either the OABI or EABI. True, OABI is deprecated, but it still clearly points the fact that FLAT is *not* an ABI, but a binary format.

Therefore, I think we should introduce config options like:

config BR2_BINFMT_ELF
bool

Quoted 8 lines

config BR2_BINFMT_FDPIC
bool

config BR2_BINFMT_FLAT
bool

probably with a choice list or something.

OK.

Quoted 11 lines
Quoted 11 lines

if BR2_arm || BR2_armeb
source "arch/Config.in.arm"
endif

package/Makefile.in +0 -0
index a8bf36b..acfd9c8 100644
@@ -103,6 +103,14 @@ TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET
 TARGET_CXXFLAGS = $(TARGET_CFLAGS)
 TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS))
 
Quoted 7 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 108

Quoted 3 lines
package/Makefile.in +3 -0
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+TARGET_LDFLAGS += -Wl,-elf2flt
+endif

This will have to use some BR2_BINFMT_FLAT config option, as per the discussion above.

OK.

Quoted 11 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 112

Quoted 3 lines
package/Makefile.in +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif

I'm still not entirely happy with that. This define is completely non-standard, I am not sure we want to have this at the global level. autotools-based packages should be fixed to check if fork() is available or not. For other packages, this special flag can be introduced on a per-package basis. But it's true that maybe a good number of packages will need that. Not sure here. What do others think?

Quoted 5 lines

Macro __NOMMU__ is not used only for fork/vfork. There are some difference between MMU and NOMMU application. For example:
- exit(n) should be replaced by _exit(n) in child process.
- Large buffer or array shouldn't be defined on stack.
- calloc() should be replaced by malloc().

More difference:
- Multi-process application should be converted into multi-thread application other than vfork if these processes are running concurrently.
- Frequent memory allocation and free code should be converted to allocate a big memory poll at the beginning of the application or replaced by nedmalloc API.

Regards,

Sonic

#19 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

In reply to Sonic Zhang

Dear Sonic Zhang,

Thanks for following up on this discussion!

Quoted 12 lines · Sonic Zhang
Quoted 12 lines

For example, on ARM, you can have ELF or FLAT binaries, that follow either the OABI or EABI. True, OABI is deprecated, but it still clearly points the fact that FLAT is *not* an ABI, but a binary format.

Therefore, I think we should introduce config options like:

config BR2_BINFMT_ELF
bool

config BR2_BINFMT_FDPIC
bool

Quoted 7 lines
Quoted 5 lines

config BR2_BINFMT_FLAT
bool

probably with a choice list or something.

OK.

It would be good if this BR2_BINFMT_<foo> thing was introduced as a separate patch. It can be part of the same patch series, but it would be could to see it introduced separately from the Blackfin additions.

Quoted 12 lines
Quoted 11 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 112

Quoted 3 lines
package/Makefile.in +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif

I'm still not entirely happy with that. This define is completely non-standard, I am not sure we want to have this at the global level. autotools-based packages should be fixed to check if fork() is available or not. For other packages, this special flag can be introduced on a per-package basis. But it's true that maybe a good number of packages will need that. Not sure here. What do others think?

Quoted 7 lines

Macro __NOMMU__ is not used only for fork/vfork. There are some difference between MMU and NOMMU application. For example:
- exit(n) should be replaced by _exit(n) in child process.
- Large buffer or array shouldn't be defined on stack.
- calloc() should be replaced by malloc().

All these changes to MMU application should be protected by macro __NOMMU__

The issue I have is that this __NOMMU__ define is, as far as I know, entirely non-standard. So whenever you will send a patch for a package that introduces some #ifdef __NOMMU__ ... #endif clause, we'll have no way of pushing it upstream.

Have you managed to pushed upstream noMMU related changes that are guarded using __NOMMU__ ?

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines

# Configure step. Only define it if not already defined by the package

package/pkg-generic.mk +0 -0
index 57b0fd0..5ce32f9 100644
@@ -303,6 +303,11 @@ endif
 
 $(2)_REDISTRIBUTE            ?= YES
 
Quoted 7 lines

package/pkg-generic.mk endif · line 310

Quoted 5 lines
package/pkg-generic.mk +5 -0
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_FLAT_LDFLAGS = -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)
+ endif
+endif

How is this one supposed to work? Who will use <pkg>_FLAT_LDFLAGS?

Quoted 4 lines

If the generic package wants to be built into FLAT binary, it should append this package specific link flag <pkg>_FLAT_LDFLAGS to the build command line in its makefile. This flag can't be added to TARGET_LDFLAGS, because it is package specific.

Hum, right, but then it means that we should modify *all* our packages so that they add $(<pkg>_FLAT_LDFLAGS) to their LDFLAGS ? Having to change the recipe of all packages doesn't seem easy to do. Maybe with enough $ signs we can delay the expansion of TARGET_LDFLAGS so that we can use a package specific variable in it. Makefile experts? Arnout? :-)

Best 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
#20 lore raw

PATCH v3 1/2 package: Makefile.in: Add target compilation flags for NOMMU architecture.

Hi Thomas,

Quoted 21 lines · Thomas Petazzoni

Dear Sonic Zhang,

Thanks for following up on this discussion!

Quoted 15 lines · Sonic Zhang
Quoted 15 lines

For example, on ARM, you can have ELF or FLAT binaries, that follow either the OABI or EABI. True, OABI is deprecated, but it still clearly points the fact that FLAT is *not* an ABI, but a binary format.

Therefore, I think we should introduce config options like:

config BR2_BINFMT_ELF
bool

config BR2_BINFMT_FDPIC
bool

config BR2_BINFMT_FLAT
bool

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

probably with a choice list or something.

OK.

It would be good if this BR2_BINFMT_<foo> thing was introduced as a separate patch. It can be part of the same patch series, but it would be could to see it introduced separately from the Blackfin additions.

No problem.

Quoted 18 lines
Quoted 18 lines
Quoted 11 lines

package/Makefile.in TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET · line 112

Quoted 3 lines
package/Makefile.in +3 -0
+ifneq ($(BR2_USE_MMU), y)
+TARGET_CFLAGS += -D__NOMMU__
+endif

I'm still not entirely happy with that. This define is completely non-standard, I am not sure we want to have this at the global level. autotools-based packages should be fixed to check if fork() is available or not. For other packages, this special flag can be introduced on a per-package basis. But it's true that maybe a good number of packages will need that. Not sure here. What do others think?

Macro __NOMMU__ is not used only for fork/vfork. There are some difference between MMU and NOMMU application. For example:
- exit(n) should be replaced by _exit(n) in child process.
- Large buffer or array shouldn't be defined on stack.
- calloc() should be replaced by malloc().

Quoted 7 lines
Quoted 1 line

All these changes to MMU application should be protected by macro __NOMMU__

The issue I have is that this __NOMMU__ define is, as far as I know, entirely non-standard. So whenever you will send a patch for a package that introduces some #ifdef __NOMMU__ ... #endif clause, we'll have no way of pushing it upstream.

Busybox uses macro ENABLE_NOMMU.
Linux kernel uses macro CONFIG_MMU.
Blackfin buildroot distribution uses __NOMMU__.

Which one do you prefer? We are fine to unify the NOMMU macro name.

Quoted 3 lines

Have you managed to pushed upstream noMMU related changes that are guarded using __NOMMU__ ?

Because no major Linux distributions support NOMMU architecture except for the blackfin one and the resource shortage in ADI Linux team, we have never tried to push the NOMMU patch to upstream packages.

Quoted 22 lines
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines

# Configure step. Only define it if not already defined by the package

package/pkg-generic.mk +0 -0
index 57b0fd0..5ce32f9 100644
@@ -303,6 +303,11 @@ endif
 
 $(2)_REDISTRIBUTE            ?= YES
 
Quoted 7 lines

package/pkg-generic.mk endif · line 310

Quoted 5 lines
package/pkg-generic.mk +5 -0
+ifeq ($(BR2_TARGET_ABI_FLAT),y)
+ ifneq ($$($(2)_FLAT_STACKSIZE),)
+  $(2)_FLAT_LDFLAGS = -Wl,-elf2flt=-s$$($(2)_FLAT_STACKSIZE)
+ endif
+endif

How is this one supposed to work? Who will use <pkg>_FLAT_LDFLAGS?

Quoted 4 lines

If the generic package wants to be built into FLAT binary, it should append this package specific link flag <pkg>_FLAT_LDFLAGS to the build command line in its makefile. This flag can't be added to TARGET_LDFLAGS, because it is package specific.

Quoted 5 lines

Hum, right, but then it means that we should modify *all* our packages so that they add $(<pkg>_FLAT_LDFLAGS) to their LDFLAGS ? Having to change the recipe of all packages doesn't seem easy to do. Maybe with enough $ signs we can delay the expansion of TARGET_LDFLAGS so that we can use a package specific variable in it. Makefile experts? Arnout? :-)

The default FLAT stack size is 4K bytes without the package specific link flag. If the package doesn't need more than 4K byte stack, nothing needs to be changed to its makefile.

Regards,

Sonic