Closed myan-o closed 1 month 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.
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?
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?
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; }
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" }
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
After removing -DL_addsubsf3, the compilation went through.
Macro definition in lib1funcs.S doesn't seem to work
It seems that the macro is not visible in #include "ieee754-sf.S".
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?
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
Closing due to lack of details and author inactivity
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?
build.sh
xgcc -v