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

[Rust cargo-first builds] Build the GCC toolchains for Windows with --with-gnu-ld to avoid too-long-command-line linking errors (IDFGH-6187) #7864

Closed
ivmarkov opened this issue Nov 10, 2021 · 13 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Feature Request Feature request for IDF

Comments

@ivmarkov
Copy link
Contributor

For various reasons which are unavoidable, the Rust builds driven via cargo do generate a very long linker command line, which goes above the 32767 character limit on Windows.

There is an escape hatch we are taking advantage of, which is to supply (most of) the link command-line arguments to the xtensa-esp32-elf-gcc.exe executable in a file. E.g. @F:\\... ...\\linker_args.txt

Unfortunately, when xtensa-esp32-elf-gcc.exe is itself calling the LD executable, it does expand the command line arguments supplied in the @ file, and thus we have the too-long-command-line problem again, but this time further down the process chain.

It seems the above file expansion does not happen, as long as the GCC toolchain for windows is compiled with the --with-gnu-ld flag enabled.

Therefore, we would like to request the GCC toolchains for Windows to always be build with --with-gnu-ld flag enabled.

@ivmarkov ivmarkov added the Type: Feature Request Feature request for IDF label Nov 10, 2021
@ivmarkov
Copy link
Contributor Author

@N3xed, @iggr, @georgik ^^^

@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 10, 2021
@github-actions github-actions bot changed the title [Rust cargo-first builds] Build the GCC toolchains for Windows with --with-gnu-ld to avoid too-long-command-line linking errors [Rust cargo-first builds] Build the GCC toolchains for Windows with --with-gnu-ld to avoid too-long-command-line linking errors (IDFGH-6187) Nov 10, 2021
@antmak
Copy link
Collaborator

antmak commented Nov 10, 2021

@ivmarkov There is a build with using --with-gnu-ld https://dl.espressif.com/dl/toolchains/preview/withgnuld/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-7-gec835ae-win64.zip . Could you try it if helps, please?

@ivmarkov
Copy link
Contributor Author

@ivmarkov There is a build with using --with-gnu-ld https://dl.espressif.com/dl/toolchains/preview/withgnuld/xtensa-esp32-elf-gcc8_4_0-esp-2021r1-7-gec835ae-win64.zip . Could you try it if helps, please?

As mentioned here I've checked and it indeed does work.

@antmak
Copy link
Collaborator

antmak commented Nov 10, 2021

Checked, thanks! We will add this fix in the next toolchain release for Windows

@ivmarkov
Copy link
Contributor Author

@antmak Any ETA when the next toolchain release for Windows is expected?
By the way, we need this fix for all of the toolchains (that is esp32, esp32c3, esp32s2, esp32s3, ..., ulp).

@TD-er
Copy link
Contributor

TD-er commented Dec 26, 2021

Yep would really like to have this as my project now needs to generate temporary cpp files and exclude the other .cpp files to make it compile in Windows.
This is often quite a frustration as I keep then editing those temp files (I know after N times I should know better, with N probably over 100).
Also I just hope this does not cause other issues too...

So looking forward to this fix.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jan 11, 2022
@georgik
Copy link
Collaborator

georgik commented Jan 12, 2022

@antmak Please, can you share details about the solution. AFAIK there is an update in tools.json. Espressif-bot just closed the issue without details.

@georgik
Copy link
Collaborator

georgik commented Jan 12, 2022

@JurajSadel - can you confirm the solution by results of your tests?

@ivmarkov
Copy link
Contributor Author

@antmak @georgik @JurajSadel I assume we "just" need to do a export ESP_IDF_VERSION=master; cargo build --features native build of the demo or the esp-idf-template on Windows and confirm that it does link successfully.

The problem is that since one week or so we cannot build against ESP-IDF master (4.4 and 4.3.X work fine): https://github.com/esp-rs/esp-idf-template/actions/runs/1681595816

@N3xed ^^^

@igrr
Copy link
Member

igrr commented Jan 12, 2022

@ivmarkov That's right, if you pull latest master branch of IDF there should be a new version of gcc for Windows installable as usual (tools.json / idf_tools.py / Windows installer / etc...). This version is built with --with-gnu-ld flag.
We are backporting this update to release/v4.4 as well.

@antmak
Copy link
Collaborator

antmak commented Jan 12, 2022

Thanks igrr.

Also you can cherry-pick commit d836163 into your IDF work directory or branch. Or download archives with -patch2 suffix from the commit manually

JFI, gcc shows its built options:

C:\> xtensa-esp32-elf-gcc -v
Using built-in specs.
COLLECT_GCC=C:\Users\mak\.espressif\tools\xtensa-esp32-elf\esp-2021r2-patch2-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe
COLLECT_LTO_WRAPPER=c:/users/mak/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch2-8.4.0/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/8.4.0/lto-wrapper.exe
Target: xtensa-esp32-elf
Configured with: /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-host_w64-mingw32 --target=xtensa-esp32-elf --prefix=/builds/idf/crosstool-NG/builds/xtensa-esp32-elf --with-local-prefix=/builds/idf/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf --with-headers=/builds/idf/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG esp-2021r2-patch2' --disable-__cxa_atexit --enable-cxx-flags=-ffunction-sections --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/buildtools/complibs-host --with-mpfr=/builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/buildtools/complibs-host --with-mpc=/builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/buildtools/complibs-host --with-isl=/builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/buildtools/complibs-host --enable-lto --enable-target-optspace --without-long-double-128 --disable-nls --enable-multiarch --enable-languages=c,c++ --disable-libstdcxx-verbose --enable-threads=posix --enable-gcov-custom-rtio --enable-libstdcxx-time=yes --with-gnu-ld
Thread model: posix
gcc version 8.4.0 (crosstool-NG esp-2021r2-patch2) 

There is --with-gnu-ld opt now

@Jason2866
Copy link

@antmak @igrr Can you upload the new toolchains to the Platformio registry?
Or are the already there? If yes can you tell us the version to use it in platformio?
Thx!

@antmak
Copy link
Collaborator

antmak commented Jan 14, 2022

@Jason2866 There were some issues with uploading the update to Platformio due to its limitation. Will be updated soon

espressif-bot pushed a commit that referenced this issue Jan 14, 2022
dskulina pushed a commit to playable-tech/esp-idf that referenced this issue Feb 4, 2022
dskulina pushed a commit to playable-tech/esp-idf that referenced this issue Feb 5, 2022
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress labels Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

7 participants