[PATCH v2 1/1] sandbox: fix build failure with musl and SDL

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Tue Feb 8 17:24:03 CET 2022


On 2/8/22 16:16, Simon Glass wrote:
> On Sat, 29 Jan 2022 at 07:17, Heinrich Schuchardt
> <heinrich.schuchardt at canonical.com> wrote:
>>
>>
>>
>> On 1/28/22 10:08, Heinrich Schuchardt wrote:
>>> sdl.c is compiled against the SDL library.
>>>
>>> Trying to redefine wchar_t with -fshort-wchar is not necessary
>>> and leads to build failures when compiling against musl.
>>>
>>> Cc: Milan P. Stanić <mps at arvanta.net>
>>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
>>> ---
> 
> Reviewed-by: Simon Glass <sjg at chromium.org>
> 
> How do I compile against musl?

On Ubuntu install the musl-tools package and use musl-gcc as your compiler.

You can add a new alternative for cc with

sudo update-alternatives --install /usr/bin/cc cc 
/usr/bin/x86_64-linux-musl-gcc 10

and choose the active alternative with

sudo update-alternatives --config cc

But this will give you problems with the include paths for libraries 
like openssl.

A better choice is using a distro like Alpine which defaults to musl. 
You can easily test it in docker.

Best regards

Heinrich

> 
> Regards,
> Simon
> 
>>> v2:
>>>        fix a build error with clang by adding -fno-lto for building sdl.o
>>>
>>> A better longterm solution will be to eliminate -fshort-wchar completely.
>>> This will require replacing %ls printf() codes by something that gcc does
>>> not check, e.g. %pS. Further all L"" strings must be replaced by u""
>>> strings.
>>
>> %p will not work as a replacement for %ls:
>>
>> warning: precision used with ‘%p’ gnu_printf format [-Wformat=]
>>     298 |                 s += sprintf(s, "%-.*ps", slen, fp->str);
>>         |                                      ^
>>
>> Best regards
>>
>> Heinrich



More information about the U-Boot mailing list