espressif / crosstool-NG

crosstool-NG with support for Xtensa
Other
121 stars 63 forks source link

Assembly code macros not working #53

Closed myan-o closed 1 month ago

myan-o commented 6 months ago

I have defined a macro in lib1funcs.S, but it seems that the macro is not visible in #include "ieee754-sf.S". It seems like there will be an error if it is commented out. If the file has a large number of characters, it seems to cause a macro undefined error. Is there a limit to the buffer size?

/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
: Assembler messages:
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:11: Error: unknown opcode or format name 'lea
f_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:21: Error: unknown opcode or format name 'lea
f_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:27: Error: unknown opcode or format name 'lea
f_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:45: Error: unknown opcode or format name 'lea
f_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:55: Error: unknown opcode or format name 'lea
f_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:67: Error: unknown opcode or format name 'lea
f_entry'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:141: Error: unknown opcode or format name 'le
af_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:183: Error: unknown opcode or format name 'le
af_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:196: Error: unknown opcode or format name 'le
af_return'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:207: Error: unknown opcode or format name 'do
_nsau'
/data/data/com.termux/files/usr/tmp/ccfRtRCu.s
:232: Error: unknown opcode or format name 'le
af_return'

build.sh

#!/bin/bash
# after of "ct-ng xtensa-esp32s3-elf"
ROOT_DIR="/data/data/com.termux/files/home/git/crosstool-NG"
BUILD_DIR="$ROOT_DIR/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/"

${BUILD_DIR}/build/build-cc-gcc-core/gcc/xgcc \
  -B${BUILD_DIR}/build/build-cc-gcc-core/gcc/ \
  -B${BUILD_DIR}/buildtools/xtensa-esp32s3-elf/bin/ \
  -B${BUILD_DIR}/buildtools/xtensa-esp32s3-elf/lib/ \
  -isystem ${BUILD_DIR}/buildtools/xtensa-esp32s3-elf/include \
  -isystem ${BUILD_DIR}/buildtools/xtensa-esp32s3-elf/sys-include \
  -I${BUILD_DIR}/src/gcc/libgcc \
  -I${BUILD_DIR}/src/gcc/gcc \
  -I${BUILD_DIR}/src/gcc/include \
  -o _addsubsf3_s.o \
  -DL_addsubsf3 \
  -c ${BUILD_DIR}src/gcc/libgcc/config/xtensa/lib1funcs.S

xgcc -v

Using built-in specs.
COLLECT_GCC=/data/data/com.termux/files/home/g
it/crosstool-NG/.build-xtensa-esp32s3-elf/xten
sa-esp32s3-elf//build/build-cc-gcc-core/gcc/xg
cc
Target: xtensa-esp32s3-elf
Configured with: /data/data/com.termux/files/h
ome/git/crosstool-NG/.build-xtensa-esp32s3-elf
/xtensa-esp32s3-elf/src/gcc/configure --build=
aarch64-linux-android --host=aarch64-linux-and
roid --target=xtensa-esp32s3-elf --prefix=/dat
a/data/com.termux/files/home/git/crosstool-NG/
.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/b
uildtools --exec_prefix=/data/data/com.termux/
files/home/git/crosstool-NG/.build-xtensa-esp3
2s3-elf/xtensa-esp32s3-elf/buildtools --with-l
ocal-prefix=/data/data/com.termux/files/home/g
it/crosstool-NG/builds/xtensa-esp32s3-elf/xten
sa-esp32s3-elf --with-sysroot=/data/data/com.t
ermux/files/home/git/crosstool-NG/builds/xtens
a-esp32s3-elf/xtensa-esp32s3-elf --with-native
-system-header-dir=/include --with-newlib --en
able-threads=no --disable-shared --with-pkgver
sion='crosstool-NG esp-13.2.0_20240305' --disa
ble-__cxa_atexit --disable-libgomp --disable-l
ibmudflap --disable-libmpx --disable-libssp --
disable-libquadmath --disable-libquadmath-supp
ort --disable-libstdcxx-verbose --disable-libs
tdcxx --with-gmp=/data/data/com.termux/files/h
ome/git/crosstool-NG/.build-xtensa-esp32s3-elf
/xtensa-esp32s3-elf/buildtools --with-mpfr=/da
ta/data/com.termux/files/home/git/crosstool-NG
/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/
buildtools --with-mpc=/data/data/com.termux/fi
les/home/git/crosstool-NG/.build-xtensa-esp32s
3-elf/xtensa-esp32s3-elf/buildtools --with-isl
=/data/data/com.termux/files/home/git/crosstoo
l-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-
elf/buildtools --enable-lto --enable-target-op
tspace --without-long-double-128 --disable-nls
 --enable-multiarch --enable-languages=c --ena
ble-threads=posix --with-gnu-ld --disable-__cx
a_atexit --without-headers   --disable-bootstr
ap --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zst
d
gcc version 12.2.0 (crosstool-NG esp-13.2.0_20
240305) 
igrr commented 6 months ago

Assembler on its own doesn't support C preprocesor directives like #include. When you compile an assembly source file using GCC, there is an option to automatically run the source file through C preprocesor before passing it to the assembler. By default, GCC decides whether to do this or not based on the file extension. Assembly source files with .S extension are passed through the preprocesor, source files with .s extension are not. You can override this behavior using -x assembler-with-cpp option.

myan-o commented 6 months ago

Where should I set it? If I set it to "CT_EXTRA_CFLAGS_FOR_BUILD" or "CT_EXTRA_CFLAGS_FOR_HOST", I get a syntax error when compiling test.c.

Are there instructions for building xtensa-esp32s3-elf?

igrr commented 6 months ago

Could you please describe what you are trying to do? What is the contents of test.c? What command are you running to compile it?

myan-o commented 6 months ago

Could you please describe what you are trying to do? What is the contents of test.c? What command are you running to compile it?

the contents of test.c int main() { return 0; }

myan-o commented 6 months ago

build options

if [ uname -o == "Android" ] then config_value "$CT_CONFIG_FILE" "CT_CFLAGS_FOR_BUILD" "-I${PREFIX}/include -fPIE" config_value "$CT_CONFIG_FILE" "CT_LDFLAGS_FOR_BUILD" "-L${PREFIX}/lib -fPIE -pie" config_value "$CT_CONFIG_FILE" "CT_EXTRA_CFLAGS_FOR_BUILD" "-I${PREFIX}/include -fPIE" config_value "$CT_CONFIG_FILE" "CT_EXTRA_LDFLAGS_FOR_BUILD" "-L${PREFIX}/lib -fPIE -pie" config_value "$CT_CONFIG_FILE" "CT_EXTRA_CFLAGS_FOR_HOST" "-I${PREFIX}/include -fPIE" config_value "$CT_CONFIG_FILE" "CT_EXTRA_LDFLAGS_FOR_HOST" "-L${PREFIX}/lib -fPIE -pie" config_append "$CT_CONFIG_FILE" ".*_EXTRA_CONFIG_ARRAY" "\2 --with-gnu-ld --disable-__cxa_atexit --without-headers" fi

config_value "$CT_CONFIG_FILE" "CT_HOST" "$CT_HOST" config_value "$CT_CONFIG_FILE" "CT_BUILD" "$CT_BUILD" config_value "$CT_CONFIG_FILE" "CT_WORK_DIR" "$CT_WORK_DIR" config_value "$CT_CONFIG_FILE" "CT_BUILD_TOP_DIR" "\${CT_WORK_DIR}/\${CT_TARGET}" config_value "$CT_CONFIG_FILE" "CT_SRC_DIR" "\${CT_BUILD_TOP_DIR}/src" config_enable "$CT_CONFIG_FILE" "CT_DEBUG_CT_SAVE_STEPS" config_append "$CT_CONFIG_FILE" ".*_EXTRA_CONFIG_ARRAY" "\2 --disable-bootstrap --disable-werror" config_append "$CT_CONFIG_FILE" "CT_EXTRA_CFLAGS_FOR_BUILD" "\2 -x assembler-with-cpp" config_append "$CT_CONFIG_FILE" "CT_EXTRA_CFLAGS_FOR_HOST" "\2 -x assembler-with-cpp"

config_enable "$CT_CONFIG_FILE" "CT_EXPERIMENTAL" config_enable "$CT_CONFIG_FILE" "CT_ALLOW_BUILD_AS_ROOT" config_enable "$CT_CONFIG_FILE" "CT_ALLOW_BUILD_AS_ROOT_SURE" }

myan-o commented 6 months ago

Even if the -x assembler-with-cpp option is specified, an error occurs.

cd crosstool-NG/
.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/build
/build-cc-gcc-core/xtensa-esp32s3-elf/libgcc

make

# If this is the top-level multilib, build all the other
# multilibs.
make[1]: Entering directory '/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/build/build-cc-gcc-core/xtensa-esp32s3-elf/libgcc'
make[2]: Entering directory '/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/build/build-cc-gcc-core/xtensa-esp32s3-elf/esp32-psram/libgcc'
# If this is the top-level multilib, build all the other
# multilibs.
/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/build/build-cc-gcc-core/./gcc/xgcc -B/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/build/build-cc-gcc-core/./gcc/ -B/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/buildtools/xtensa-esp32s3-elf/bin/ -B/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/buildtools/xtensa-esp32s3-elf/lib/ -isystem /data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/buildtools/xtensa-esp32s3-elf/include -isystem /data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/buildtools/xtensa-esp32s3-elf/sys-include    -g -O2 -mlongcalls -idirafter /data/data/com.termux/files/home/git/crosstool-NG/builds/xtensa-esp32s3-elf/xtensa-esp32s3-elf/include -g -Os -x assembler-with-cpp -mfix-esp32-psram-cache-issue -O2  -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -mlongcalls -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -mlongcalls -I. -I. -I../../.././gcc -I/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/src/gcc/libgcc -I/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/src/gcc/libgcc/. -I/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/src/gcc/libgcc/../gcc -I/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/src/gcc/libgcc/../include  -DHAVE_CC_TLS  -x assembler-with-cpp  -o _addsubsf3_s.o -MT _addsubsf3_s.o -MD -MP -MF _addsubsf3_s.dep -DSHARED -DL_addsubsf3 -xassembler-with-cpp -c /data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/src/gcc/libgcc/config/xtensa/lib1funcs.S
/data/data/com.termux/files/usr/tmp/ccoYgST1.s: Assembler messages:
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:18: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:28: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:34: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:52: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:62: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:74: Error: unknown opcode or format name 'leaf_entry'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:148: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:190: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:203: Error: unknown opcode or format name 'leaf_return'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:214: Error: unknown opcode or format name 'do_nsau'
/data/data/com.termux/files/usr/tmp/ccoYgST1.s:239: Error: unknown opcode or format name 'leaf_return'
make[2]: *** [Makefile:491: _addsubsf3_s.o] Error 1
make[2]: Leaving directory '/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/build/build-cc-gcc-core/xtensa-esp32s3-elf/esp32-psram/libgcc'
make[1]: *** [Makefile:1211: multi-do] Error 1
make[1]: Leaving directory '/data/data/com.termux/files/home/git/crosstool-NG/.build-xtensa-esp32s3-elf/xtensa-esp32s3-elf/build/build-cc-gcc-core/xtensa-esp32s3-elf/libgcc'
make: *** [Makefile:127: all-multi] Error 2
myan-o commented 6 months ago

After removing -DL_addsubsf3, the compilation went through.

myan-o commented 6 months ago

Macro definition in lib1funcs.S doesn't seem to work

myan-o commented 6 months ago

It seems that the macro is not visible in #include "ieee754-sf.S".

myan-o commented 6 months ago

If the file has a large number of characters, it seems to cause a macro undefined error. Is there a limit to the buffer size?

Lapshin commented 5 months ago

Are there instructions for building xtensa-esp32s3-elf?

xtensa-esp32s3-elf is a part of xtensa-esp-elf toolchain. To build refer to .gitlab-ci.yml script https://github.com/espressif/crosstool-NG/blob/esp-1.26.x/.gitlab-ci.yml#L239-L247

Lapshin commented 1 month ago

Closing due to lack of details and author inactivity