core.a 在 Arduino 构建过程中来自哪里?

Where does core.a come from in the Arduino build process?

我正在尝试围绕 Arduino C++ 库生成一个 Rust 包装器(现在我的目标是 Adafruit_NeoPixel)。我一直在使用 strace 来弄清楚 Arduino IDE execs.

我目前确信 core.a 是该过程的重要组成部分,因为它出现在 ld 调用中。

2337  execve("/usr/libexec/gcc/avr/ld", ["/usr/libexec/gcc/avr/ld", "-plugin", "/usr/libexec/gcc/avr/11.2.0/liblto_plugin.so", "-plugin-opt=/usr/libexec/gcc/avr/11.2.0/lto-wrapper", "-plugin-opt=-fresolution=/tmp/ccqWVTle.res", "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lm", "-plugin-opt=-pass-through=-lc", "-plugin-opt=-pass-through=-latmega328p", "-mavr5", "-Tdata", "0x800100", "-o", "/tmp/arduino_build_966100/sketch_jan13a.ino.elf", "/usr/lib/gcc/avr/11.2.0/../../../../avr/lib/avr5/crtatmega328p.o", "-L/tmp/arduino_build_966100", "-L/usr/lib/gcc/avr/11.2.0/avr5", "-L/usr/lib/gcc/avr/11.2.0/../../../../avr/lib/avr5", "-L/usr/lib/gcc/avr/11.2.0", "-L/usr/lib/gcc/avr/11.2.0/../../../../avr/lib", "--gc-sections", "/tmp/arduino_build_966100/sketch/sketch_jan13a.ino.cpp.o", "/tmp/arduino_build_966100/core/core.a", "-lm", "--start-group", "-lgcc", "-lm", "-lc", "-latmega328p", "--end-group"], 0x12d9410 /* 62 vars */ <unfinished ...>

 $ ar t /tmp/arduino_build_966100/core/core.a
wiring_pulse.S.o
WInterrupts.c.o
hooks.c.o
wiring.c.o
wiring_analog.c.o
wiring_digital.c.o
wiring_pulse.c.o
wiring_shift.c.o
CDC.cpp.o
HardwareSerial.cpp.o
HardwareSerial0.cpp.o
HardwareSerial1.cpp.o
HardwareSerial2.cpp.o
HardwareSerial3.cpp.o
IPAddress.cpp.o
PluggableUSB.cpp.o
Print.cpp.o
Stream.cpp.o
Tone.cpp.o
USBCore.cpp.o
WMath.cpp.o
WString.cpp.o
abi.cpp.o
main.cpp.o
new.cpp.o

它出现在 /tmp/arduino_build_* 草图构建目录中,但我不确定它来自哪里。我在 /usr/share/arduino.

中找不到它

core.a 是如何创建的?

TLDR:/usr/share/arduino/hardware/arduino/avr/cores/arduino/(Linux)中有一堆文件变成了 core.a

鉴于 aMike 的评论,我能够从 arduino IDE:

观察到这一点
Compiling libraries...
Compiling core...
"/usr/bin/avr-gcc" -c -g -x assembler-with-cpp -flto -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_pulse.S" -o "/tmp/arduino_build_26920/core/wiring_pulse.S.o"
"/usr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/WInterrupts.c" -o "/tmp/arduino_build_26920/core/WInterrupts.c.o"
"/usr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/hooks.c" -o "/tmp/arduino_build_26920/core/hooks.c.o"
"/usr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring.c" -o "/tmp/arduino_build_26920/core/wiring.c.o"
"/usr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_analog.c" -o "/tmp/arduino_build_26920/core/wiring_analog.c.o"
"/usr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_digital.c" -o "/tmp/arduino_build_26920/core/wiring_digital.c.o"
"/usr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_pulse.c" -o "/tmp/arduino_build_26920/core/wiring_pulse.c.o"
"/usr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/wiring_shift.c" -o "/tmp/arduino_build_26920/core/wiring_shift.c.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/CDC.cpp" -o "/tmp/arduino_build_26920/core/CDC.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp" -o "/tmp/arduino_build_26920/core/HardwareSerial.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial0.cpp" -o "/tmp/arduino_build_26920/core/HardwareSerial0.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial1.cpp" -o "/tmp/arduino_build_26920/core/HardwareSerial1.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial2.cpp" -o "/tmp/arduino_build_26920/core/HardwareSerial2.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/HardwareSerial3.cpp" -o "/tmp/arduino_build_26920/core/HardwareSerial3.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/IPAddress.cpp" -o "/tmp/arduino_build_26920/core/IPAddress.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/PluggableUSB.cpp" -o "/tmp/arduino_build_26920/core/PluggableUSB.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/Print.cpp" -o "/tmp/arduino_build_26920/core/Print.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/Stream.cpp" -o "/tmp/arduino_build_26920/core/Stream.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/Tone.cpp" -o "/tmp/arduino_build_26920/core/Tone.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/USBCore.cpp" -o "/tmp/arduino_build_26920/core/USBCore.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/WMath.cpp" -o "/tmp/arduino_build_26920/core/WMath.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/WString.cpp" -o "/tmp/arduino_build_26920/core/WString.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/abi.cpp" -o "/tmp/arduino_build_26920/core/abi.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/main.cpp" -o "/tmp/arduino_build_26920/core/main.cpp.o"
"/usr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/usr/share/arduino/hardware/arduino/avr/cores/arduino" "-I/usr/share/arduino/hardware/arduino/avr/variants/standard" "/usr/share/arduino/hardware/arduino/avr/cores/arduino/new.cpp" -o "/tmp/arduino_build_26920/core/new.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/wiring_pulse.S.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/WInterrupts.c.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/hooks.c.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/wiring.c.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/wiring_analog.c.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/wiring_digital.c.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/wiring_pulse.c.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/wiring_shift.c.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/CDC.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/HardwareSerial.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/HardwareSerial0.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/HardwareSerial1.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/HardwareSerial2.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/HardwareSerial3.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/IPAddress.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/PluggableUSB.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/Print.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/Stream.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/Tone.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/USBCore.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/WMath.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/WString.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/abi.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/main.cpp.o"
"/usr/bin/avr-gcc-ar" rcs  "/tmp/arduino_build_26920/core/core.a" "/tmp/arduino_build_26920/core/new.cpp.o"
Archiving built core (caching) in: /tmp/arduino_cache_784519/core/core_arduino_avr_uno_1621df717313d057c92202babd71649a.a

我什至设法让这些文件在 Rust 中编译 build.rs

截至 2022 年 1 月,我已经设法将其封装在几个板条箱中:https://github.com/mutantbob/rust-arduino-helpers。它的边缘 非常 粗糙,部分原因是我对嵌入式 Rust 开发非常陌生,部分原因是我对 Rust 相当陌生。好消息是,我已经使用它成功地将 Rust 程序与以太网和 Adafruit_NeoPixel.

等 C++ 库链接起来