Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Library names with spaces fail

> On 13 Sep 2019, at 01:53, Liviu Ionescu <ilg@xxxxxxxxxx> wrote:
> (I had to override `ensurePathIsGNUMakeTargetRuleCompatibleSyntax()` since `ensureUnquoted()` is static and cannot be overridden).

my explanation was a bit terse, so here is a more detailed one.

for reasons that I do not know, the list of libraries is not passed to the linker directly by expanding the value of the option (of type LIBS), but by passing the $(LIBS) variable and asking make to do the substitution.

in, the USER_OBJS and LIBS variables is initialised by appending the corresponding lists.

the code to do this is in populateObjectsMakefile():

at line 1069, the paths are processed by calling `ensurePathIsGNUMakeTargetRuleCompatibleSyntax()` to keep make happy, which practically means to escape whitespaces.

this function is at line 4363:

and calls the static `ensureUnquoted()` at line 4647. (not static is very fortunate, since statics cannot be overridden in derived classes).

this function strips quotes or double quotes and allow the caller to later escape whitespaces.

for USER_OBJS this is ok, since the value of the option is a list of strings that contains paths, and the result looks like

USER_OBJS := /Users/ilg/My\ Files/WKS\ Projects/xpack-dev-tools.github/arm-none-eabi-gcc-xpack.git/tests/eclipse/arm\ exe\ obj\ spaces/objs\ folder/obj\ file.o

however, for LIBS, the input list contains library names prefixed by -l, with names surrounded by double quotes, but the first one is not at the 0 index, but 2 character later, like

[ -l"arm static lib spaces" ]

thus ensureUnquoted() fails to detect the quotes, and they are not removed from the string. 

later on white spaces are escaped, and the current results includes both double quotes and escaped spaces, like:

LIBS := -l"arm\ static\ lib\ spaces"

make is definitely not happy with this syntax, and the link step fails.

the correct line should be:

LIBS := -larm\ static\ lib\ spaces

my temporary hack in ensureUnquoted() is to further look inside the string and detect the -l prefix, but this is not very nice, a more generic solution should be designed, since this function is also called from other places, and other prefixes might be encountered.

hope this helps.


Back to the top