diff mbox

[RFC,v2,2/5] aarch64: ilp32: handle special file name

Message ID 1426672192-21041-3-git-send-email-bamvor.zhangjian@huawei.com
State Changes Requested
Headers show

Commit Message

Bamvor Jian Zhang March 18, 2015, 9:49 a.m. UTC
In aarch64 ilp32, the directory of library is libilp32 and the linker is
ld-linux-aarch64_ilp32.so.1 or ld-linux-aarch64_be_ilp32.so.1.

Signed-off-by: Zhang Jian(Bamvor) <bamvor.zhangjian@huawei.com>
---
 Makefile                                           |  9 +++++
 toolchain/helpers.mk                               |  4 +--
 toolchain/toolchain-external/toolchain-external.mk | 41 ++++++++++++++++++++--
 3 files changed, 50 insertions(+), 4 deletions(-)

Comments

Gustavo Zacarias April 10, 2015, 12:35 p.m. UTC | #1
On 03/18/2015 06:49 AM, Zhang Jian(Bamvor) wrote:

> In aarch64 ilp32, the directory of library is libilp32 and the linker is
> ld-linux-aarch64_ilp32.so.1 or ld-linux-aarch64_be_ilp32.so.1.

There's a couple of issues here, let's see...

> +ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
> +# Leave extension for x32 on x86_64 which is libx32 instead of libx32
> +ifeq ($(BR2_aarch64), y)
> +LIB_SYMLINK = libilp32
> +endif
> +ifeq ($(BR2_aarch64_be), y)
> +LIB_SYMLINK = libilp32
> +endif
> +endif

You can simplify this:

ifeq ($(BR2_aarch64)$(BR2_aarch64_be),y)
ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
LIB_SYMLINK = libilp32
endif
endif

aarch64 & aarch64_be won't be defined at the same time so you can
condense it in a single ifeq.
Also the comment doesn't apply IMHO, there's nothing related to x86_64
here yet.
Additionally it has to be aarch64 before it can be ilp32 right? And is
"ilp32" used for any other architecture? If not you could remove the
whole aarch64 clause.

> +ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
> +LIB_EXTERNAL_LIBS += ld*.so
> +endif

Can we focus this a little bit more like it's done for ARM EABIhf
instead of just copying ld* blindly?
Otherwise the rest looks ok from a quick look/without having a toolchain
to test things.
Regards.
Bamvor Jian Zhang April 13, 2015, 10:12 a.m. UTC | #2
On 2015/4/10 20:35, Gustavo Zacarias wrote:
> On 03/18/2015 06:49 AM, Zhang Jian(Bamvor) wrote:
> 
>> In aarch64 ilp32, the directory of library is libilp32 and the linker is
>> ld-linux-aarch64_ilp32.so.1 or ld-linux-aarch64_be_ilp32.so.1.
> 
> There's a couple of issues here, let's see...
> 
>> +ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
>> +# Leave extension for x32 on x86_64 which is libx32 instead of libx32
>> +ifeq ($(BR2_aarch64), y)
>> +LIB_SYMLINK = libilp32
>> +endif
>> +ifeq ($(BR2_aarch64_be), y)
>> +LIB_SYMLINK = libilp32
>> +endif
>> +endif
> 
> You can simplify this:
> 
> ifeq ($(BR2_aarch64)$(BR2_aarch64_be),y)
> ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
> LIB_SYMLINK = libilp32
> endif
> endif
> 
> aarch64 & aarch64_be won't be defined at the same time so you can
> condense it in a single ifeq.
> Also the comment doesn't apply IMHO, there's nothing related to x86_64
> here yet.
> Additionally it has to be aarch64 before it can be ilp32 right? And is
> "ilp32" used for any other architecture? If not you could remove the
> whole aarch64 clause.
Ilp32 is used in x86_64 too. But the name of ilp32 in x86_64 is x32.
> 
>> +ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
>> +LIB_EXTERNAL_LIBS += ld*.so
>> +endif
> 
> Can we focus this a little bit more like it's done for ARM EABIhf
> instead of just copying ld* blindly?
Oh, it is ld-VERSION.so in libilp32 directory. The ld-linux-aarch64_ilp32.so.1
is only existed in lib directory. And ld-linux-aarch64_ilp32.so.1 is the
only file I need in lib. So, here, I just skip the lib directory.

regards

bamvor
> Otherwise the rest looks ok from a quick look/without having a toolchain
> to test things.
> Regards.
> 
>
Bamvor Jian Zhang April 13, 2015, 10:16 a.m. UTC | #3
On 2015/4/13 18:12, Bamvor Jian Zhang wrote:
> On 2015/4/10 20:35, Gustavo Zacarias wrote:
>> On 03/18/2015 06:49 AM, Zhang Jian(Bamvor) wrote:
>>
>>> In aarch64 ilp32, the directory of library is libilp32 and the linker is
>>> ld-linux-aarch64_ilp32.so.1 or ld-linux-aarch64_be_ilp32.so.1.
>>
>> There's a couple of issues here, let's see...
>>
>>> +ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
>>> +# Leave extension for x32 on x86_64 which is libx32 instead of libx32
>>> +ifeq ($(BR2_aarch64), y)
>>> +LIB_SYMLINK = libilp32
>>> +endif
>>> +ifeq ($(BR2_aarch64_be), y)
>>> +LIB_SYMLINK = libilp32
>>> +endif
>>> +endif
>>
>> You can simplify this:
>>
>> ifeq ($(BR2_aarch64)$(BR2_aarch64_be),y)
>> ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
>> LIB_SYMLINK = libilp32
>> endif
>> endif
>>
>> aarch64 & aarch64_be won't be defined at the same time so you can
>> condense it in a single ifeq.
>> Also the comment doesn't apply IMHO, there's nothing related to x86_64
>> here yet.
>> Additionally it has to be aarch64 before it can be ilp32 right? And is
>> "ilp32" used for any other architecture? If not you could remove the
>> whole aarch64 clause.
> Ilp32 is used in x86_64 too. But the name of ilp32 in x86_64 is x32.
>>
>>> +ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
>>> +LIB_EXTERNAL_LIBS += ld*.so
>>> +endif
>>
>> Can we focus this a little bit more like it's done for ARM EABIhf
>> instead of just copying ld* blindly?
> Oh, it is ld-VERSION.so in libilp32 directory. The ld-linux-aarch64_ilp32.so.1
> is only existed in lib directory. And ld-linux-aarch64_ilp32.so.1 is the
> only file I need in lib. So, here, I just skip the lib directory.
> 
> regards
> 
> bamvor
>> Otherwise the rest looks ok from a quick look/without having a toolchain
>> to test things.
Well, you could test it with the toolchain built by linaro ABE. The abe script
and the source of linaro gcc is public, but the toolchain binary with ilp32
support is not public.
I contact with linaro guys last month. They told me that linaro will not
provide the toolchain binary with ilp32 support until the libilp32 is upstreamed.

regards

bamvor
>> Regards.
>>
>>
> 
>
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 84402be..0fbb12a 100644
--- a/Makefile
+++ b/Makefile
@@ -456,6 +456,15 @@  LIB_SYMLINK = lib64
 else
 LIB_SYMLINK = lib32
 endif
+ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
+# Leave extension for x32 on x86_64 which is libx32 instead of libx32
+ifeq ($(BR2_aarch64), y)
+LIB_SYMLINK = libilp32
+endif
+ifeq ($(BR2_aarch64_be), y)
+LIB_SYMLINK = libilp32
+endif
+endif
 
 $(STAGING_DIR):
 	@mkdir -p $(STAGING_DIR)/bin
diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 3121da4..ffb5c72 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -38,7 +38,7 @@ 
 #
 # $1: arch specific sysroot directory
 # $2: support libraries directory (can be empty)
-# $3: library directory ('lib' or 'lib64') from which libraries must be copied
+# $3: library directory ('lib', 'lib64' or 'libilp32') from which libraries must be copied
 # $4: library name
 # $5: destination directory of the libary, relative to $(TARGET_DIR)
 #
@@ -140,7 +140,7 @@  copy_toolchain_sysroot = \
 	for i in etc $${ARCH_LIB_DIR} sbin usr usr/$${ARCH_LIB_DIR}; do \
 		if [ -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
 			rsync -au --chmod=Du+w --exclude 'usr/lib/locale' \
-				--exclude lib --exclude lib32 --exclude lib64 \
+				--exclude lib --exclude lib32 --exclude lib64 --exclude libilp32 \
 				$${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
 		fi ; \
 	done ; \
diff --git a/toolchain/toolchain-external/toolchain-external.mk b/toolchain/toolchain-external/toolchain-external.mk
index c0429bb..2bb0a39 100644
--- a/toolchain/toolchain-external/toolchain-external.mk
+++ b/toolchain/toolchain-external/toolchain-external.mk
@@ -86,6 +86,10 @@  ifeq ($(BR2_TOOLCHAIN_EXTERNAL_MUSL),y)
 LIB_EXTERNAL_LIBS += libc.so libgcc_s.so.*
 endif
 
+ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
+LIB_EXTERNAL_LIBS += ld*.so
+endif
+
 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
 USR_LIB_EXTERNAL_LIBS += libstdc++.so.*
 endif
@@ -253,6 +257,19 @@  define TOOLCHAIN_EXTERNAL_LINARO_AARCH64_SYMLINK
 	ln -sf . $(TARGET_DIR)/usr/lib/aarch64-linux-gnu
 endef
 
+ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
+ifeq ($(BR2_ENDIAN), "LITTLE")
+define TOOLCHAIN_EXTERNAL_ILP32_SYMLINK
+	ln -sf ld*.so $(TARGET_DIR)/lib/ld-linux-aarch64_ilp32.so.1
+endef
+endif
+ifeq ($(BR2_ENDIAN), "BIG")
+define TOOLCHAIN_EXTERNAL_ILP32_SYMLINK
+	ln -sf ld*.so $(TARGET_DIR)/lib/ld-linux-aarch64_be_ilp32.so.1
+endef
+endif
+endif
+
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201305),y)
 TOOLCHAIN_EXTERNAL_SITE = http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi
 TOOLCHAIN_EXTERNAL_SOURCE = arm-2013.05-24-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
@@ -400,6 +417,7 @@  else
 # Custom toolchain
 TOOLCHAIN_EXTERNAL_SITE = $(dir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
 TOOLCHAIN_EXTERNAL_SOURCE = $(notdir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL)))
+TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_EXTERNAL_ILP32_SYMLINK
 endif
 
 # In fact, we don't need to download the toolchain, since it is already
@@ -444,13 +462,13 @@  endef
 
 # Returns the sysroot location for the given compiler + flags
 define toolchain_find_sysroot
-$$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:(usr/)?lib(32|64)?/([^/]*/)?libc\.a::')
+$$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:(usr/)?lib(32|64|ilp32)?/([^/]*/)?libc\.a::')
 endef
 
 # Returns the lib subdirectory for the given compiler + flags (i.e
 # typically lib32 or lib64 for some toolchains)
 define toolchain_find_libdir
-$$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64)?)/([^/]*/)?libc.a:\2:')
+$$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64|ilp32)?)/([^/]*/)?libc.a:\2:')
 endef
 
 # Checks for an already installed toolchain: check the toolchain
@@ -716,10 +734,28 @@  define TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT
 	fi
 endef
 
+ifeq ($(BR2_GCC_TARGET_ABI), "ilp32")
+ifeq ($(BR2_ENDIAN), "LITTLE")
+ILP32_SYM = ld-linux-aarch64_ilp32.so.1
+else
+ILP32_SYM = ld-linux-aarch64_be_ilp32.so.1
+endif
+define TOOLCHAIN_EXTERNAL_INSTALL_ILP32_LINK
+	LD_ILP32=`basename $(STAGING_DIR)/lib/ld*.so`; \
+	ln -sf $${LD_ILP32} $(STAGING_DIR)/lib/${ILP32_SYM}
+endef
+
+define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_ILP32_LINK
+	LD_ILP32=`basename $(TARGET_DIR)/lib/ld*.so`; \
+	ln -sf $${LD_ILP32} $(TARGET_DIR)/lib/${ILP32_SYM}
+endef
+endif
+
 define TOOLCHAIN_EXTERNAL_INSTALL_STAGING_CMDS
 	$(TOOLCHAIN_EXTERNAL_INSTALL_SYSROOT_LIBS)
 	$(TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER)
 	$(TOOLCHAIN_EXTERNAL_INSTALL_GDBINIT)
+	$(TOOLCHAIN_EXTERNAL_INSTALL_ILP32_LINK)
 endef
 
 # Even though we're installing things in both the staging, the host
@@ -729,6 +765,7 @@  define TOOLCHAIN_EXTERNAL_INSTALL_TARGET_CMDS
 	$(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_LIBS)
 	$(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC)
 	$(TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FLAT)
+	$(TOOLCHAIN_EXTERNAL_INSTALL_TARGET_ILP32_LINK)
 endef
 
 $(eval $(generic-package))