Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Any plans for Tensilica Xtensa support? #964

Open
DatanoiseTV opened this issue Jan 15, 2023 · 13 comments
Open

Feature request: Any plans for Tensilica Xtensa support? #964

DatanoiseTV opened this issue Jan 15, 2023 · 13 comments

Comments

@DatanoiseTV
Copy link

The Tensilica Xtensa cores is used in the popular ESP32 MCU. There is gcc and upcoming llvm support for it, but would be great to see mold support for the Xtensa targets (especially LX6), because the linking of projects takes minutes sometimes.

@rui314
Copy link
Owner

rui314 commented Jan 16, 2023

It doesn't seem to be too hard to support it, but I don't know how to test the result. I just installed gcc-xtensa-lx106 package to my Ubuntu, but xtensa-lx106-elf-gcc (and GNU ld) couldn't build even a "Hello world" program.

@DatanoiseTV
Copy link
Author

DatanoiseTV commented Jan 16, 2023

@rui314
Copy link
Owner

rui314 commented Jan 16, 2023

It looks like it's a bit too much to install a third-party SDK to add a new target to the mold linker. Are you working for Espressif? If there's a business interest in doing this, I'm happy to talk on what condition we can work together.

@rui314
Copy link
Owner

rui314 commented Jan 16, 2023

It looks like I can't still produce a working "hello world" program with the SDK.

$ cat /tmp/foo.c
#include <stdio.h>
int main() { printf("Hello world\n"); }

$ bin/xtensa-esp32-elf-gcc -o /tmp/foo /tmp/foo.c
/tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/lib/libc.a(lib_a-stdio.o):(.literal+0x1c): warning: _close_r is not implemented and will always fail
/tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/lib/libc.a(lib_a-makebuf.o):(.literal+0x0): warning: _fstat_r is not implemented and will always fail
/tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/lib/libc.a(lib_a-stdio.o):(.literal+0xc): warning: _lseek_r is not implemented and will always fail
/tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/lib/libc.a(lib_a-stdio.o):(.literal+0x4): warning: _read_r is not implemented and will always fail
/tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/lib/libc.a(lib_a-stdio.o):(.literal+0x10): warning: _write_r is not implemented and will always fail
/tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/lib/libc.a(lib_a-puts.o):(.literal+0x1c): warning: pthread_setcancelstate is not implemented and will always fail
/tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/bin/ld: /tmp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/11.2.0/../../../../xtensa-esp32-elf/lib/libc.a(lib_a-puts.o):(.literal+0x30): warning: __getreent is not implemented and will always fail

$ qemu-xtensa -L /tmp/xtensa-esp32-elf/lib /tmp/foo
Segmentation fault (core dumped)

@DatanoiseTV
Copy link
Author

That is weird. This seems related? espressif/esp-idf#5308
Afaics, qemu with the standard tensilica core can not run ESP32 code.

@DatanoiseTV
Copy link
Author

@rui314 Let me know if I can help somehow.

@rui314
Copy link
Owner

rui314 commented Jan 25, 2023

I just don't need an SDK at this moment but we need to keep maintaining once we start supporting the target, which includes setting up a GitHub CI and such. It looks like maintaining the Xtensa target isn't easy enough for us given the situation. We usually support only targets that we can install cross compilers via apt-get.

@igrr
Copy link

igrr commented Feb 24, 2023

Hi, I saw this issue linked to espressif/esp-idf#5308 and wanted to leave a hello-world recipe:

$ xtensa-esp32-elf-gcc -specs=sim.elf.specs -specs=sys.qemu.specs -o /tmp/foo /tmp/foo.c
$ qemu-system-xtensa -nographic --semihosting -cpu esp32 -M esp32 -kernel /tmp/foo
Not initializing SPI Flash
Warning: both -bios and -kernel arguments specified. Only loading the the -kernel file.
Hello world

using this toolchain release and this qemu release.

While this specific toolchain can't be installed via apt-get, it is available as part of our SDK docker images, which should work for the purpose of GitHub CI.

I think running this with the upstream Qemu and user mode emulation (qemu-xtensa) should also be possible, but we don't have the right GCC specs file for that yet. I'll add this to our todo list.

@DatanoiseTV
Copy link
Author

@igrr Off topic, but does the qemu for xtensa also support the S2/S3 series? I am primarely working with S3 nowadays and it would be great to see it.

@igrr
Copy link

igrr commented Feb 24, 2023

Unfortunately it doesn't, but you can subscribe to espressif/qemu#42 to get notified if we implement it. I can't promise any timeline, sorry.

@rui314
Copy link
Owner

rui314 commented Feb 24, 2023

Our test suite does not use qemu-system but qemu-user and assumes that all the targets are running a Unix-like system. I.e. our test suite is not for baremetal programming. This does not block us from supporting Xtensa, but that's something we need to deal with besides supporting Xtensa itself if we want to support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants