pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ESP32 toolchain



On Mon, Dec 15, 2025 at 09:52:19PM +0100, Frédéric Fauberteau wrote:
> Perhaps I haven't looked hard enough, but I haven't seen an option to
> specify the endianness with xtensa-esp-elf-gcc.

From memory, it's part of the -mcpu spec. 

> 
> I use the PlatformIO framework and I found a similar naming:
> 
> % find ~/.platformio/packages -name "xtensa*gcc"
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin/xtensa-esp32-elf-gcc
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp32s3@8.4.0+2021r2-patch5/bin/xtensa-esp32s3-elf-gcc
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp32s3/bin/xtensa-esp32s3-elf-gcc
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32s2-elf-gcc
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp-elf-gcc
> /Users/triaxx/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32-elf-gcc

That's the older xtensa toolchain I guess (I have gcc version 8.4.0
(crosstool-NG esp-2021r2-patch5) from platformio).
Our package it at 13.2.0, and xtensa's builds now have an unified toochain
which supports multiple variants of the architectures.
AFAIK pkgsrc just followed what upstream is doing.

I found what I did for my attemps at using our toolchain. Upstream
provides a wrapper, with xtensa-esp32-elf-* as symlinks to the wrapper; so
I wrote a perl wrapper to do the same thing:
-rwxr-xr-x  1 bouyer  wheel  388 Oct 15 19:12 wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-addr2line -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-ar -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-as -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-c++ -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-c++filt -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-cpp -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-elfedit -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-g++ -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-gcc -> wrap.pl
lrwxr-xr-x  1 bouyer  wheel    7 Oct 15 16:53 xtensa-esp32-elf-gcc-13.2.0 -> wrap.pl

and so on. The perl wrapper is attached. It adds '-mdynconfig=xtensa_esp32.so'
to the command line and XTENSA_GNU_CONFIG

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
#!/usr/pkg/bin/perl

my $prog;
if ($0 =~ /xtensa-(esp32)-elf-(.+)/)
{
	$prog = $2;
} else {
	die "bad name $0";
}

if ($prog =~ /^(c\+\+|c\+\+filt|cpp|g\+\+|gcc)$/)
{
	unshift @ARGV, '-mdynconfig=xtensa_esp32.so';
}
$ENV{'XTENSA_GNU_CONFIG'} = '/usr/pkg/xtensa-esp-elf/lib/xtensa_esp32.so';
exec '/usr/pkg/xtensa-esp-elf/bin/xtensa-esp-elf-' . $prog, @ARGV or die "can't exec $prog: $!";


Home | Main Index | Thread Index | Old Index