diff mbox

toolchain-wrapper: fix breakage after host/usr removal

Message ID 20170707074330.27294-1-arnout@mind.be
State Accepted
Headers show

Commit Message

Arnout Vandecappelle July 7, 2017, 7:43 a.m. UTC
The toolchain wrapper, when called through PATH, strips the last three
levels of /proc/self/exe to find HOST_DIR. However, after the host/usr
removal, this should be just two levels.

The toolchain wrapper has different logic for when it is called with a
full path (i.e. $HOST_DIR/usr/bin/arm-linux-gcc) then when it is called
through the PATH (i.e. just arm-linux-gcc). The latter is never used
internally in Buildroot, that's why this wasn't discovered through
testing.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Cc: Mark Jackson <mpfj-list@newflow.co.uk>
---
Sorry for the breakage :-)

Note to self: add a test for calling the toolchain through PATH.

To fix an existing toolchain without rebuilding:
make host-gcc-final-rebuild
(or make host-toolchain-external-custom-rebuild if that's what you're
using).
---
 toolchain/toolchain-wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Jackson July 7, 2017, 11:12 a.m. UTC | #1
On 07/07/17 08:43, Arnout Vandecappelle (Essensium/Mind) wrote:
> The toolchain wrapper, when called through PATH, strips the last three
> levels of /proc/self/exe to find HOST_DIR. However, after the host/usr
> removal, this should be just two levels.
> 
> The toolchain wrapper has different logic for when it is called with a
> full path (i.e. $HOST_DIR/usr/bin/arm-linux-gcc) then when it is called
> through the PATH (i.e. just arm-linux-gcc). The latter is never used
> internally in Buildroot, that's why this wasn't discovered through
> testing.
> 
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> Cc: Mark Jackson <mpfj-list@newflow.co.uk>

Tested-by: Mark Jackson <mpfj-list@newflow.co.uk>

Works fine now.  Cheers.

> ---
> Sorry for the breakage :-)
> 
> Note to self: add a test for calling the toolchain through PATH.
> 
> To fix an existing toolchain without rebuilding:
> make host-gcc-final-rebuild
> (or make host-toolchain-external-custom-rebuild if that's what you're
> using).
> ---
>   toolchain/toolchain-wrapper.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c
> index 3a4455ff82..a73e6d6f94 100644
> --- a/toolchain/toolchain-wrapper.c
> +++ b/toolchain/toolchain-wrapper.c
> @@ -192,7 +192,7 @@ int main(int argc, char **argv)
>   		for (i = ret; i > 0; i--) {
>   			if (absbasedir[i] == '/') {
>   				absbasedir[i] = '\0';
> -				if (++count == 3)
> +				if (++count == 2)
>   					break;
>   			}
>   		}
>
Thomas Petazzoni July 7, 2017, 11:58 a.m. UTC | #2
Hello,

On Fri, 7 Jul 2017 09:43:30 +0200, Arnout Vandecappelle
(Essensium/Mind) wrote:
> The toolchain wrapper, when called through PATH, strips the last three
> levels of /proc/self/exe to find HOST_DIR. However, after the host/usr
> removal, this should be just two levels.
> 
> The toolchain wrapper has different logic for when it is called with a
> full path (i.e. $HOST_DIR/usr/bin/arm-linux-gcc) then when it is called
> through the PATH (i.e. just arm-linux-gcc). The latter is never used
> internally in Buildroot, that's why this wasn't discovered through
> testing.
> 
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> Cc: Mark Jackson <mpfj-list@newflow.co.uk>
> ---
> Sorry for the breakage :-)

Applied to master, thanks.

Thomas
diff mbox

Patch

diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c
index 3a4455ff82..a73e6d6f94 100644
--- a/toolchain/toolchain-wrapper.c
+++ b/toolchain/toolchain-wrapper.c
@@ -192,7 +192,7 @@  int main(int argc, char **argv)
 		for (i = ret; i > 0; i--) {
 			if (absbasedir[i] == '/') {
 				absbasedir[i] = '\0';
-				if (++count == 3)
+				if (++count == 2)
 					break;
 			}
 		}