1

I'm using this tool-chian provided by a manufacture of control boards.

I followed the instruction step by step but when I tried to compile example code, the compilation process got stuck at "$basename can't execute" branch of the if clause.

I'm not exactly a wizard of bash scripts so I have no idea what I'm looking at.

#!/bin/bash

# uclibc-toolchain-wrapper




basename=$0

if [ -d $basename ]
then
    echo "This can't be a directory."
    exit 1;
fi

tool_name=${basename##*/}
if [[ $tool_name =~ "mips-linux-uclibc-gnu" ]]
then
    prefix=${basename%-uclibc-*}
    postfix=${basename##*mips-linux-uclibc}
    $prefix$postfix "-muclibc" $@
else
    echo "$basename can't execute."
    exit 1;
fi

So what should I do to get this script rolling?

The user manual told me to modify environment variables in order to "install" the tool chain. Which consists basically of adding a designated path to "PATH" variable in .bashrc. Of course I've placed the entire toolchain inside the designated folder.

When I type "make" command in the source folder, the toolchain does appear to be called upon, but the execution stops at this script with an error printout:"uclibc-toolchain-wrapper can't execute". Where "uclibc-toolchain-wrapper" is the filename of this script.

I've tried this on lubuntu 13, ubuntu 22, Debian 5 and all met the same result.

Please help! Thanks in advance!

11
  • What exactly does it tell you that you can't execute? The tool is ripping apart tool names, so unless you're running them exactly as specified it's likely to fail Aug 29, 2022 at 8:10
  • The tool name must contain mips-linux-uclibc-gnu in its name Aug 29, 2022 at 8:12
  • @roaima Hi thank you for your response, what do you mean by "the tool"? What tool? I don't know much of anything about tool chains to apologize in advance. It told me itself, yes, the name of the script file can't execute. And the name of the script file is "uclibc-toolchain-wrapper".
    – cream_pi
    Aug 29, 2022 at 8:58
  • 2
    Please edit your question to show the actual message instead of "the compilation process got stuck at "$basename can't execute"" (i.e. replace $basename with the real name) Aug 29, 2022 at 10:44
  • @roaima Honestly I don't even know what $basename is. This is the original script, I didn't modify any critical information.
    – cream_pi
    Aug 29, 2022 at 11:07

1 Answer 1

1

In the beginning of the script, $basename is set to be equal to $0 which means "the name (possibly including a directory path) this script was executed as".

The apparent purpose of this script is to be linked/copied to several different names, like cc1-mips-linux-uclibc-gnu for the first phase of the compiler. When executed using that name, it rearranges the command to cc1-mips-linux-gnu -muclibc <script parameters> and attempts to execute that.

From this, it would seem that the toolchain package might contain several executable tools named like:

<tool name>-mips-linux-gnu<possible suffix>

This wrapper would then presumably be linked as:

<tool name>-mips-linux-uclibc-gnu<possible suffix>

for each of them, to allow the use of long-form tool names that include the -uclibc- part.

If you run ls -lF in a directory that contains the toolchain's executables, you might/should see symbolic links like:

cc1-mips-linux-uclibc-gnu -> uclibc-toolchain-wrapper
<some tool>-mips-linux-uclibc-gnu -> uclibc-toolchain-wrapper
<another tool>-mips-linux-uclibc-gnu -> uclibc-toolchain-wrapper
...

and either in the same directory, or elsewhere within the toolchain package, there would be executables named like:

cc1-mips-linux-gnu
<some tool>-mips-linux-gnu
<another tool>-mips-linux-gnu
...

The <some tool>, <another tool> etc. might be well-known compiler/linker component names like cpp, ld etc., or other tools.


But if the literal error message you're getting when you run make is

uclibc-toolchain-wrapper can't execute

then the script is detecting it's being run as just uclibc-toolchain-wrapper, which is not correct: this script expects to be called using any name that includes the string mips-linux-uclibc-gnu. This is literally the test that causes the "$basename cannot execute" error messages if it fails.

Have you extracted the toolchain package to a non-Unix-like filesystem (like NTFS) and trying to run it from there? On such filesystems, symbolic link semantics might not work the same as on Unix-like filesystems, and that might explain why the script is not being able to get the original name of the symbolic link used to run the script, and gets the real name of the script (uclibc-toolchain-wrapper) instead. In this case, the fix would be to re-extract the toolchain package to a real Unix-like filesystem instead, and use it from there.

Or if the Makefile literally calls the script using the name uclibc-toolchain-wrapper, then that Makefile is being silly and/or somehow misconfigured.

1
  • Hello TelcoM, you are spot on about the "symbolic links" part. But not just that, I did a oopsie by chmoding 777 the shrapnel out of the extracted folder, and that alone seem to have royally drew up the folder, because I naively and ignorantly believe that for anything to execute, you need to elevate its privilege. I still don't understand your answer 100% but the problem has been solved thanks to your response. Thank you!
    – cream_pi
    Sep 8, 2022 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .