diff mbox

[v2,6/7] arch: Introduce blackfin-specific Makefile

Message ID 1364550643-11793-6-git-send-email-sonic.adi@gmail.com
State Changes Requested
Headers show

Commit Message

Sonic Zhang March 29, 2013, 9:50 a.m. UTC
From: Sonic Zhang <sonic.zhang@analog.com>

v2-changes:
- Remove useless Macro __uClinux__

v1-changes:
- Create arch makefile.
- Create blackfin makefile.
- Add FDPIC and FLAT library options and makefile targets to install
libraries for different binary formats into the same rootfs image.
- update the TARGET_EXCEPTIONS variable in support/scripts/graph-depends for
new custom targets

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 Makefile                      |    2 ++
 arch/Config.in.bfin           |   21 +++++++++++++++++++++
 arch/Makefile.in              |    5 +++++
 arch/Makefile.in.bfin         |   22 ++++++++++++++++++++++
 support/scripts/graph-depends |    2 ++
 5 files changed, 52 insertions(+), 0 deletions(-)
 create mode 100644 arch/Makefile.in
 create mode 100644 arch/Makefile.in.bfin

Comments

Thomas Petazzoni April 7, 2013, 9:41 p.m. UTC | #1
Dear Sonic Zhang,

On Fri, 29 Mar 2013 17:50:42 +0800, Sonic Zhang wrote:

> +config BR2_BFIN_INSTALL_FDPIC_SHARED
> +	depends on BR2_bfin && !BR2_BINFMT_FDPIC
> +	bool "Install FDPIC shared libraries"
> +	default y

Any reason to have this default to y ?

> +	help
> +	  Blackfin Linux kernel supports running both FDPIC and FLAT applications

	  The Blackfin Linux kernel ...

> +	  concurrently if the binary format specific libraries installed properly.

							are installed properly.

> +	  This option allow developer to install FDPIC libraries into a buildroot

			allows the developer

> +	  rootfs image built with binary format macro other than BR2_BINFMT_FDPIC.

			built with a binary format that is not FDPIC.

> +
> +config BR2_BFIN_INSTALL_FLAT_SHARED
> +	depends on BR2_bfin && !BR2_BINFMT_FLAT_SHARED
> +	bool "Install FLAT shared libraries"
> +	default y
> +	help
> +	  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 FLAT libraries into a buildroot
> +	  rootfs image built with binary format macro other than
> +	  BR2_BINFMT_FLAT_SHARED.

Same typos.

> diff --git a/arch/Makefile.in.bfin b/arch/Makefile.in.bfin
> new file mode 100644
> index 0000000..9089bc5
> --- /dev/null
> +++ b/arch/Makefile.in.bfin
> @@ -0,0 +1,22 @@
> +TARGETS_BFIN-$(BR2_BFIN_INSTALL_FDPIC_SHARED) += target-shared-libs-fdpic
> +TARGETS_BFIN-$(BR2_BFIN_INSTALL_FLAT_SHARED) += target-shared-libs-flat
> +TARGETS += $(TARGETS_BFIN-y)
> +
> +CROSS_COMPILE_SHARED_FDPIC ?= bfin-linux-uclibc-
> +target-shared-libs-fdpic:
> +	set -e; \
> +	t=`$(CROSS_COMPILE_SHARED_FDPIC)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_FDPIC)readelf -d "$$i" | sed -n '/(SONAME)/s:.*[[]\(.*\)[]].*:\1:p'`; \
> +		$(INSTALL) -D $$i $(TARGET_DIR)/lib/$$soname; \
> +	done
> +
> +CROSS_COMPILE_SHARED_FLAT ?= bfin-uclinux-
> +target-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

I am still not happy with this, because it simply doesn't work unless
you have the Blackfin toolchain installed globally on your system,
which simply isn't the case for normal users.

So I believe we should extend the external toolchain logic to be able
to use three variants of the Blackfin toolchain:

	* Only FDPIC
	* Only FLAT
	* Both FLAT and FDPIC

And then, this logic should be moved in the external toolchain logic,
where we already do the process of copying libraries from the toolchain
to the target, and from the toolchain to the staging directory.

Also:

 * $(CPUFLAGS) isn't defined anywhere

 * the logic to determine which .so files to copy should use the
   $(LIB_EXTERNAL_LIBS) and $(USR_LIB_EXTERNAL_LIBS) that we already
   use in ext-tool.mk.

 * I don't quite understand the logic you're using for the shared flat
   library copying. You use -print-file-name=libc, but then you copy it
   under the name 'lib1.so'. I think a comment above this part would be
   useful.

Thanks!

Thomas
Sonic Zhang April 8, 2013, 7:19 a.m. UTC | #2
Hi Thomas,

On Mon, Apr 8, 2013 at 5:41 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Dear Sonic Zhang,
>
> On Fri, 29 Mar 2013 17:50:42 +0800, Sonic Zhang wrote:
>
>> +config BR2_BFIN_INSTALL_FDPIC_SHARED
>> +     depends on BR2_bfin && !BR2_BINFMT_FDPIC
>> +     bool "Install FDPIC shared libraries"
>> +     default y
>
> Any reason to have this default to y ?

No. Can be removed.

>
>> +     help
>> +       Blackfin Linux kernel supports running both FDPIC and FLAT applications
>
>           The Blackfin Linux kernel ...
>
>> +       concurrently if the binary format specific libraries installed properly.
>
>                                                         are installed properly.
>
>> +       This option allow developer to install FDPIC libraries into a buildroot
>
>                         allows the developer
>
>> +       rootfs image built with binary format macro other than BR2_BINFMT_FDPIC.
>
>                         built with a binary format that is not FDPIC.
>
>> +
>> +config BR2_BFIN_INSTALL_FLAT_SHARED
>> +     depends on BR2_bfin && !BR2_BINFMT_FLAT_SHARED
>> +     bool "Install FLAT shared libraries"
>> +     default y
>> +     help
>> +       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 FLAT libraries into a buildroot
>> +       rootfs image built with binary format macro other than
>> +       BR2_BINFMT_FLAT_SHARED.
>
> Same typos.

Thanks.

>
>> diff --git a/arch/Makefile.in.bfin b/arch/Makefile.in.bfin
>> new file mode 100644
>> index 0000000..9089bc5
>> --- /dev/null
>> +++ b/arch/Makefile.in.bfin
>> @@ -0,0 +1,22 @@
>> +TARGETS_BFIN-$(BR2_BFIN_INSTALL_FDPIC_SHARED) += target-shared-libs-fdpic
>> +TARGETS_BFIN-$(BR2_BFIN_INSTALL_FLAT_SHARED) += target-shared-libs-flat
>> +TARGETS += $(TARGETS_BFIN-y)
>> +
>> +CROSS_COMPILE_SHARED_FDPIC ?= bfin-linux-uclibc-
>> +target-shared-libs-fdpic:
>> +     set -e; \
>> +     t=`$(CROSS_COMPILE_SHARED_FDPIC)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_FDPIC)readelf -d "$$i" | sed -n '/(SONAME)/s:.*[[]\(.*\)[]].*:\1:p'`; \
>> +             $(INSTALL) -D $$i $(TARGET_DIR)/lib/$$soname; \
>> +     done
>> +
>> +CROSS_COMPILE_SHARED_FLAT ?= bfin-uclinux-
>> +target-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
>
> I am still not happy with this, because it simply doesn't work unless
> you have the Blackfin toolchain installed globally on your system,
> which simply isn't the case for normal users.
>
> So I believe we should extend the external toolchain logic to be able
> to use three variants of the Blackfin toolchain:
>
>         * Only FDPIC
>         * Only FLAT
>         * Both FLAT and FDPIC
>
> And then, this logic should be moved in the external toolchain logic,
> where we already do the process of copying libraries from the toolchain
> to the target, and from the toolchain to the staging directory.

Since FPDIC libraries are installed by default if BINFMT_FDPIC is
selected, how about making INSTALL_FDPIC_LIB option depend on
BINFMT_FLAT only? So do the INSTALL_FLAT_LIB option. And no "Both FLAT
and FDPIC" is needed in this case.

>
> Also:
>
>  * $(CPUFLAGS) isn't defined anywhere

Yes, forgot to define it after switching to the toolchain wrapper solution.

>  * the logic to determine which .so files to copy should use the
>    $(LIB_EXTERNAL_LIBS) and $(USR_LIB_EXTERNAL_LIBS) that we already
>    use in ext-tool.mk.

This only applies to the FDPIC libraries. The FLAT libraries use a
different name policy.

>  * I don't quite understand the logic you're using for the shared flat
>    library copying. You use -print-file-name=libc, but then you copy it
>    under the name 'lib1.so'. I think a comment above this part would be
>    useful.

The flat libraries are found and linked according to the index in it
name "libN.so". Index 1 is reserved for the standard C library.
Customer libraries can use 4 and above. That's why the libc is renamed
to lib1.so in target rootfs.

Regards,

Sonic.
Thomas Petazzoni April 8, 2013, 9:23 p.m. UTC | #3
Dear Sonic Zhang,

On Mon, 8 Apr 2013 15:19:18 +0800, Sonic Zhang wrote:
> > I am still not happy with this, because it simply doesn't work unless
> > you have the Blackfin toolchain installed globally on your system,
> > which simply isn't the case for normal users.
> >
> > So I believe we should extend the external toolchain logic to be able
> > to use three variants of the Blackfin toolchain:
> >
> >         * Only FDPIC
> >         * Only FLAT
> >         * Both FLAT and FDPIC
> >
> > And then, this logic should be moved in the external toolchain logic,
> > where we already do the process of copying libraries from the toolchain
> > to the target, and from the toolchain to the staging directory.
> 
> Since FPDIC libraries are installed by default if BINFMT_FDPIC is
> selected, how about making INSTALL_FDPIC_LIB option depend on
> BINFMT_FLAT only? So do the INSTALL_FLAT_LIB option.

Yes, this makes sense.

> And no "Both FLAT and FDPIC" is needed in this case.

In fact, I looked again at our support for Blackfin external
toolchains, and I was wrong: we always install *both* the FDPIC and
Flat shared libraries. So in fact, you don't need to handle the
variants of the external toolchain.

Just move your logic into the external toolchain logic that copies
libraries, and that should be fine. I believe it belongs to the
external toolchain logic, because it is highly specific to Analog
Devices toolchains. If we ever support Blackfin in the internal
backend, it will always either be FDPIC *or* FLAT, but not both at the
same time.

> >  * the logic to determine which .so files to copy should use the
> >    $(LIB_EXTERNAL_LIBS) and $(USR_LIB_EXTERNAL_LIBS) that we already
> >    use in ext-tool.mk.
> 
> This only applies to the FDPIC libraries. The FLAT libraries use a
> different name policy.

Yes, sure, but I was referring to the FDPIC libraries in this part
(sorry if it wasn't clear).

> >  * I don't quite understand the logic you're using for the shared flat
> >    library copying. You use -print-file-name=libc, but then you copy it
> >    under the name 'lib1.so'. I think a comment above this part would be
> >    useful.
> 
> The flat libraries are found and linked according to the index in it
> name "libN.so". Index 1 is reserved for the standard C library.
> Customer libraries can use 4 and above. That's why the libc is renamed
> to lib1.so in target rootfs.

Oh, ok, interesting. Could you just copy/paste this explanation as a
comment above the relevant part of the code?

Thanks a lot Sonic for your very quick feedback in this discussion, I
think we're making great progress!

Thanks,

Thomas
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 7f0822f..c2f43a4 100644
--- a/Makefile
+++ b/Makefile
@@ -329,6 +329,8 @@  ifneq ($(PACKAGE_OVERRIDE_FILE),)
 -include $(PACKAGE_OVERRIDE_FILE)
 endif
 
+include arch/Makefile.in
+
 include package/*/*.mk
 
 include boot/common.mk
diff --git a/arch/Config.in.bfin b/arch/Config.in.bfin
index 021f5fe..038da4a 100644
--- a/arch/Config.in.bfin
+++ b/arch/Config.in.bfin
@@ -62,6 +62,27 @@  config BR2_bf561
 	bool "bf561"
 endchoice
 
+config BR2_BFIN_INSTALL_FDPIC_SHARED
+	depends on BR2_bfin && !BR2_BINFMT_FDPIC
+	bool "Install FDPIC shared libraries"
+	default y
+	help
+	  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.
+
+config BR2_BFIN_INSTALL_FLAT_SHARED
+	depends on BR2_bfin && !BR2_BINFMT_FLAT_SHARED
+	bool "Install FLAT shared libraries"
+	default y
+	help
+	  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 FLAT libraries into a buildroot
+	  rootfs image built with binary format macro other than
+	  BR2_BINFMT_FLAT_SHARED.
+
 config BR2_ARCH
 	default "bfin"
 
diff --git a/arch/Makefile.in b/arch/Makefile.in
new file mode 100644
index 0000000..d791118
--- /dev/null
+++ b/arch/Makefile.in
@@ -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
diff --git a/arch/Makefile.in.bfin b/arch/Makefile.in.bfin
new file mode 100644
index 0000000..9089bc5
--- /dev/null
+++ b/arch/Makefile.in.bfin
@@ -0,0 +1,22 @@ 
+TARGETS_BFIN-$(BR2_BFIN_INSTALL_FDPIC_SHARED) += target-shared-libs-fdpic
+TARGETS_BFIN-$(BR2_BFIN_INSTALL_FLAT_SHARED) += target-shared-libs-flat
+TARGETS += $(TARGETS_BFIN-y)
+
+CROSS_COMPILE_SHARED_FDPIC ?= bfin-linux-uclibc-
+target-shared-libs-fdpic:
+	set -e; \
+	t=`$(CROSS_COMPILE_SHARED_FDPIC)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_FDPIC)readelf -d "$$i" | sed -n '/(SONAME)/s:.*[[]\(.*\)[]].*:\1:p'`; \
+		$(INSTALL) -D $$i $(TARGET_DIR)/lib/$$soname; \
+	done
+
+CROSS_COMPILE_SHARED_FLAT ?= bfin-uclinux-
+target-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
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
index 1163d79..227d085 100755
--- a/support/scripts/graph-depends
+++ b/support/scripts/graph-depends
@@ -168,6 +168,8 @@  TARGET_EXCEPTIONS = [
     "erase-fakeroots",
     "target-generic-hostname",
     "target-root-passwd",
+    "target-shared-libs-fdpic",
+    "target-shared-libs-flat",
 ]
 
 # In full mode, start with the result of get_targets() to get the main