diff mbox

Makefile: Symlink lib32 to lib for MIPS64/n32

Message ID 1372675884-963-1-git-send-email-markos.chandras@gmail.com
State Superseded
Headers show

Commit Message

Markos Chandras July 1, 2013, 10:51 a.m. UTC
From: Markos Chandras <markos.chandras@imgtec.com>

gcc hardcodes the uClibc interpreter for MIPS64/n32 as follows:
(gcc-4.7.3, gcc/config/mips/linux64.h):
define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"

However, buildroot always creates the $(TARGET_DIR)/lib and
$(TARGET_DIR)/usr/lib directories, therefore for consinstency
reasons, we create a lib32->lib symlink to fix the interpreter
problems for MIPS64/n32.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
 Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Arnout Vandecappelle July 2, 2013, 5:59 a.m. UTC | #1
On 07/01/13 12:51, Markos Chandras wrote:
> From: Markos Chandras <markos.chandras@imgtec.com>
>
> gcc hardcodes the uClibc interpreter for MIPS64/n32 as follows:
> (gcc-4.7.3, gcc/config/mips/linux64.h):
> define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
>
> However, buildroot always creates the $(TARGET_DIR)/lib and
> $(TARGET_DIR)/usr/lib directories, therefore for consinstency
> reasons, we create a lib32->lib symlink to fix the interpreter
> problems for MIPS64/n32.

  I would say we do it for all 32-bit platforms. If people feel they 
can't afford the overhead of two additional inodes in their rootfs, they 
can still remove the link in a post-build script.

>
> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
> ---
>   Makefile | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index c514e4f..0059d0c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -436,6 +436,12 @@ $(BUILD_DIR)/.root:
>   		--exclude .hg --exclude=CVS --exclude '*~' \
>   		$(TARGET_SKELETON)/ $(TARGET_DIR)/
>   	cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
> +ifeq ($(BR2_MIPS_NABI32),y)
> +	pushd $(TARGET_DIR) > /dev/null 2>&1; \
> +		ln -sfn lib lib32; \
> +		ln -sfn lib usr/lib32; \

  No need for the pushd/popd; just:

	ln -sfn lib $(TARGET_DIR)/lib32
	ln -sfn lib $(TARGET_DIR)/usr/lib32


  Regards,
  Arnout

> +		popd > /dev/null 2>&1
> +endif
>   	touch $@
>
>   $(TARGET_DIR): $(BUILD_DIR)/.root
>
Markos Chandras July 2, 2013, 11:04 a.m. UTC | #2
Hi Arnout,

On 2 July 2013 06:59, Arnout Vandecappelle <arnout@mind.be> wrote:
> On 07/01/13 12:51, Markos Chandras wrote:
>>
>> From: Markos Chandras <markos.chandras@imgtec.com>
>>
>> gcc hardcodes the uClibc interpreter for MIPS64/n32 as follows:
>> (gcc-4.7.3, gcc/config/mips/linux64.h):
>> define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
>>
>> However, buildroot always creates the $(TARGET_DIR)/lib and
>> $(TARGET_DIR)/usr/lib directories, therefore for consinstency
>> reasons, we create a lib32->lib symlink to fix the interpreter
>> problems for MIPS64/n32.
>
>
>  I would say we do it for all 32-bit platforms. If people feel they can't
> afford the overhead of two additional inodes in their rootfs, they can still
> remove the link in a post-build script.

I wouldn't mind doing the symlink for the following architectures:

!mips64/n64 && !x86_64 && !sparc64. It's probably harmless.
Do I forget another architecture?

>> +ifeq ($(BR2_MIPS_NABI32),y)
>> +       pushd $(TARGET_DIR) > /dev/null 2>&1; \
>> +               ln -sfn lib lib32; \
>> +               ln -sfn lib usr/lib32; \
>
>
>  No need for the pushd/popd; just:
>
>         ln -sfn lib $(TARGET_DIR)/lib32
>         ln -sfn lib $(TARGET_DIR)/usr/lib32
>

Thanks. I will fix that in v2

--
Regards,
Markos Chandras
Markos Chandras July 2, 2013, 1:36 p.m. UTC | #3
Hi Arnout,

On 2 July 2013 06:59, Arnout Vandecappelle <arnout@mind.be> wrote:
> On 07/01/13 12:51, Markos Chandras wrote:
>>
>> From: Markos Chandras <markos.chandras@imgtec.com>
>>
>> gcc hardcodes the uClibc interpreter for MIPS64/n32 as follows:
>> (gcc-4.7.3, gcc/config/mips/linux64.h):
>> define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
>>
>> However, buildroot always creates the $(TARGET_DIR)/lib and
>> $(TARGET_DIR)/usr/lib directories, therefore for consinstency
>> reasons, we create a lib32->lib symlink to fix the interpreter
>> problems for MIPS64/n32.
>
>
>  I would say we do it for all 32-bit platforms. If people feel they can't
> afford the overhead of two additional inodes in their rootfs, they can still
> remove the link in a post-build script.
>

Is this preferred?

+ifeq ($(BR2_MIPS_NABI64)$(BR2_aarch64)$(BR2_sh64)$(BR2_x86_64),)
+       ln -sfn lib $(TARGET_DIR)/lib32; \
+               ln -sfn lib $(TARGET_DIR)/usr/lib32;
+endif

--
Regards,
Markos Chandras
Arnout Vandecappelle July 2, 2013, 4:29 p.m. UTC | #4
On 07/02/13 15:36, Markos Chandras wrote:
> Hi Arnout,
>
> On 2 July 2013 06:59, Arnout Vandecappelle <arnout@mind.be> wrote:
>> On 07/01/13 12:51, Markos Chandras wrote:
>>>
>>> From: Markos Chandras <markos.chandras@imgtec.com>
>>>
>>> gcc hardcodes the uClibc interpreter for MIPS64/n32 as follows:
>>> (gcc-4.7.3, gcc/config/mips/linux64.h):
>>> define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
>>>
>>> However, buildroot always creates the $(TARGET_DIR)/lib and
>>> $(TARGET_DIR)/usr/lib directories, therefore for consinstency
>>> reasons, we create a lib32->lib symlink to fix the interpreter
>>> problems for MIPS64/n32.
>>
>>
>>   I would say we do it for all 32-bit platforms. If people feel they can't
>> afford the overhead of two additional inodes in their rootfs, they can still
>> remove the link in a post-build script.
>>
>
> Is this preferred?
>
> +ifeq ($(BR2_MIPS_NABI64)$(BR2_aarch64)$(BR2_sh64)$(BR2_x86_64),)

  I was going to say:

ifeq ($(BR2_ARCH_IS_64),)

but only now I realise you're talking about n32 on a 64-bit MIPS. Though 
I must say, I don't understand why we call it BR2_ARCH_IS_64 if the ABI 
is 32 bit - or is it actually a 64-bit ABI that is just called n32 by 
accident?

  I also noticed now that for lib64, we only create the symlinks if they 
exists in the external toolchain, and we remove the lib64 directory in 
the internal toolchain. Perhaps this can be simplified into creating the 
lib64/lib32 links unconditionally after installing the toolchain?


> +       ln -sfn lib $(TARGET_DIR)/lib32; \
> +               ln -sfn lib $(TARGET_DIR)/usr/lib32;

  No need for the semicolon and the backslash, this can be done as two 
separate commands.


  Regards,
  Arnout

> +endif
>
> --
> Regards,
> Markos Chandras
>
>
Markos Chandras July 2, 2013, 5:55 p.m. UTC | #5
On 2 July 2013 17:29, Arnout Vandecappelle <arnout@mind.be> wrote:
> On 07/02/13 15:36, Markos Chandras wrote:

>> Is this preferred?
>>
>> +ifeq ($(BR2_MIPS_NABI64)$(BR2_aarch64)$(BR2_sh64)$(BR2_x86_64),)
>
>
>  I was going to say:
>
> ifeq ($(BR2_ARCH_IS_64),)
>
> but only now I realise you're talking about n32 on a 64-bit MIPS. Though I
> must say, I don't understand why we call it BR2_ARCH_IS_64 if the ABI is 32
> bit - or is it actually a 64-bit ABI that is just called n32 by accident?

n32 is a 64-bit ABI with 32-bit pointers (something like the new x32 for x86).

>
>  I also noticed now that for lib64, we only create the symlinks if they
> exists in the external toolchain, and we remove the lib64 directory in the
> internal toolchain. Perhaps this can be simplified into creating the
> lib64/lib32 links unconditionally after installing the toolchain?

Whatever works best. I have no strong preference on this.

>
>
>
>> +       ln -sfn lib $(TARGET_DIR)/lib32; \
>> +               ln -sfn lib $(TARGET_DIR)/usr/lib32;
>
>
>  No need for the semicolon and the backslash, this can be done as two
> separate commands.

Ok I will fix that.

--
Regards,
Markos Chandras
Arnout Vandecappelle July 2, 2013, 6:12 p.m. UTC | #6
On 07/02/13 19:55, Markos Chandras wrote:
> On 2 July 2013 17:29, Arnout Vandecappelle <arnout@mind.be> wrote:
>> On 07/02/13 15:36, Markos Chandras wrote:
>
>>> Is this preferred?
>>>
>>> +ifeq ($(BR2_MIPS_NABI64)$(BR2_aarch64)$(BR2_sh64)$(BR2_x86_64),)
>>
>>
>>   I was going to say:
>>
>> ifeq ($(BR2_ARCH_IS_64),)
>>
>> but only now I realise you're talking about n32 on a 64-bit MIPS. Though I
>> must say, I don't understand why we call it BR2_ARCH_IS_64 if the ABI is 32
>> bit - or is it actually a 64-bit ABI that is just called n32 by accident?
>
> n32 is a 64-bit ABI with 32-bit pointers (something like the new x32 for x86).

  Okay, so it's a 64-bit ABI that is called n32 by accident :-)

  Since it's not clear if lib32 is needed for other architectures, and 
since we don't always do it for the 64-bit architectures, it's probably 
better to keep your original condition on $(BR2_MIPS_NABI32).


>>   I also noticed now that for lib64, we only create the symlinks if they
>> exists in the external toolchain, and we remove the lib64 directory in the
>> internal toolchain. Perhaps this can be simplified into creating the
>> lib64/lib32 links unconditionally after installing the toolchain?
>
> Whatever works best. I have no strong preference on this.

  Probably it's best if your patch goes in as is, and it can be 
refactored later.

>>> +       ln -sfn lib $(TARGET_DIR)/lib32; \
>>> +               ln -sfn lib $(TARGET_DIR)/usr/lib32;
>>

  By the way, shouldn't the same be done in STAGING_DIR?


  Regards,
  Arnout

>>
>>   No need for the semicolon and the backslash, this can be done as two
>> separate commands.
>
> Ok I will fix that.
>
> --
> Regards,
> Markos Chandras
>
>
Markos Chandras July 2, 2013, 6:19 p.m. UTC | #7
On 2 July 2013 19:12, Arnout Vandecappelle <arnout@mind.be> wrote:
>>
>>
>> n32 is a 64-bit ABI with 32-bit pointers (something like the new x32 for
>> x86).
>
>
>  Okay, so it's a 64-bit ABI that is called n32 by accident :-)
>
>  Since it's not clear if lib32 is needed for other architectures, and since
> we don't always do it for the 64-bit architectures, it's probably better to
> keep your original condition on $(BR2_MIPS_NABI32).

Ok :)

>>>> +       ln -sfn lib $(TARGET_DIR)/lib32; \
>>>> +               ln -sfn lib $(TARGET_DIR)/usr/lib32;
>>>
>>>
>
>  By the way, shouldn't the same be done in STAGING_DIR?

I am not sure. The only problem I found was with the interpreter path
during runtime.
I can't see why lib32->lib is needed for the STAGING_DIR. Everything
in buildroot seems to depend
on lib and usr/lib and uClibc also uses MULTILIB_DIR="lib". I wouldn't
touch the STAGING_DIR for
now until I hit a real problem.

--
Regards,
Markos Chandras
diff mbox

Patch

diff --git a/Makefile b/Makefile
index c514e4f..0059d0c 100644
--- a/Makefile
+++ b/Makefile
@@ -436,6 +436,12 @@  $(BUILD_DIR)/.root:
 		--exclude .hg --exclude=CVS --exclude '*~' \
 		$(TARGET_SKELETON)/ $(TARGET_DIR)/
 	cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
+ifeq ($(BR2_MIPS_NABI32),y)
+	pushd $(TARGET_DIR) > /dev/null 2>&1; \
+		ln -sfn lib lib32; \
+		ln -sfn lib usr/lib32; \
+		popd > /dev/null 2>&1
+endif
 	touch $@
 
 $(TARGET_DIR): $(BUILD_DIR)/.root