Skip to content

Commit

Permalink
Merge branch 'feature/gcc8_use_bundled_newlib' into 'master'
Browse files Browse the repository at this point in the history
Use newlib headers and libraries from toolchain when compiling with GCC 8.2

See merge request idf/esp-idf!4450
  • Loading branch information
igrr committed Apr 11, 2019
2 parents 76b3940 + a567b6c commit 70eda3d
Show file tree
Hide file tree
Showing 36 changed files with 1,286 additions and 388 deletions.
3 changes: 2 additions & 1 deletion components/bootloader/subproject/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ target_linker_script(bootloader.elf

# as cmake won't attach linker args to a header-only library, attach
# linker args directly to the bootloader.elf
# esp32.rom.newlib-funcs.ld is included to use memset/memcpy.
set(BOOTLOADER_LINKER_SCRIPTS
"${IDF_PATH}/components/esp_rom/${IDF_TARGET}/ld/${IDF_TARGET}.rom.ld"
"${IDF_PATH}/components/esp_rom/${IDF_TARGET}/ld/${IDF_TARGET}.rom.spiram_incompatible_fns.ld"
"${IDF_PATH}/components/esp_rom/${IDF_TARGET}/ld/${IDF_TARGET}.rom.newlib-funcs.ld"
"${IDF_PATH}/components/${IDF_TARGET}/ld/${IDF_TARGET}.peripherals.ld")

target_linker_script(bootloader.elf ${BOOTLOADER_LINKER_SCRIPTS})
Expand Down
2 changes: 1 addition & 1 deletion components/bootloader/subproject/main/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LINKER_SCRIPTS := \
$(IDF_TARGET).bootloader.ld \
$(IDF_TARGET).bootloader.rom.ld \
$(IDF_PATH)/components/esp_rom/$(IDF_TARGET)/ld/$(IDF_TARGET).rom.ld \
$(IDF_PATH)/components/esp_rom/$(IDF_TARGET)/ld/$(IDF_TARGET).rom.spiram_incompatible_fns.ld \
$(IDF_PATH)/components/esp_rom/$(IDF_TARGET)/ld/$(IDF_TARGET).rom.newlib-funcs.ld \
$(IDF_PATH)/components/$(IDF_TARGET)/ld/$(IDF_TARGET).peripherals.ld

ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
Expand Down
6 changes: 6 additions & 0 deletions components/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ set(COMPONENT_PRIV_INCLUDEDIRS "include/driver")
set(COMPONENT_REQUIRES esp_ringbuf)

register_component()


if(GCC_NOT_5_2_0)
# uses C11 atomic feature
set_source_files_properties(spi_master.c PROPERTIES COMPILE_FLAGS -std=gnu11)
endif()
4 changes: 4 additions & 0 deletions components/driver/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ COMPONENT_ADD_INCLUDEDIRS := include

COMPONENT_PRIV_INCLUDEDIRS := include/driver

ifeq ($(GCC_NOT_5_2_0), 1)
# uses C11 atomic feature
spi_master.o: CFLAGS += -std=gnu11
endif
12 changes: 9 additions & 3 deletions components/esp_rom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ else()

target_linker_script(${COMPONENT_TARGET}
"esp32/ld/esp32.rom.ld"
"esp32/ld/esp32.rom.libgcc.ld")
"esp32/ld/esp32.rom.libgcc.ld"
"esp32/ld/esp32.rom.syscalls.ld"
"esp32/ld/esp32.rom.newlib-data.ld")

if(CONFIG_SPIRAM_CACHE_WORKAROUND)
target_compile_options(${COMPONENT_TARGET} PUBLIC -mfix-esp32-psram-cache-issue)
else()
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.spiram_incompatible_fns.ld")
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-funcs.ld")
endif()

if(CONFIG_NEWLIB_NANO_FORMAT)
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.nanofmt.ld")
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-nano.ld")
endif()

if(NOT GCC_NOT_5_2_0)
target_linker_script(${COMPONENT_TARGET} "esp32/ld/esp32.rom.newlib-locale.ld")
endif()

if(NOT CONFIG_SPI_FLASH_ROM_DRIVER_PATCH)
Expand Down
13 changes: 10 additions & 3 deletions components/esp_rom/component.mk
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#Linker scripts used to link the final application.
#Warning: These linker scripts are only used when the normal app is compiled; the bootloader
#specifies its own scripts.
LINKER_SCRIPTS += esp32.rom.ld esp32.rom.libgcc.ld
LINKER_SCRIPTS += esp32.rom.ld \
esp32.rom.libgcc.ld \
esp32.rom.syscalls.ld \
esp32.rom.newlib-data.ld

#SPI-RAM incompatible functions can be used in when the SPI RAM
#workaround is not enabled.
ifndef CONFIG_SPIRAM_CACHE_WORKAROUND
LINKER_SCRIPTS += esp32.rom.spiram_incompatible_fns.ld
LINKER_SCRIPTS += esp32.rom.newlib-funcs.ld
endif

ifdef CONFIG_NEWLIB_NANO_FORMAT
LINKER_SCRIPTS += esp32.rom.nanofmt.ld
LINKER_SCRIPTS += esp32.rom.newlib-nano.ld
endif

ifneq ($(GCC_NOT_5_2_0), 1)
LINKER_SCRIPTS += esp32.rom.newlib-locale.ld
endif

ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
Expand Down
28 changes: 0 additions & 28 deletions components/esp_rom/esp32/ld/esp32.rom.ld
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ PROVIDE ( Cache_Read_Init_rom = 0x40009950 );
PROVIDE ( cache_sram_mmu_set_rom = 0x400097f4 );
/* This is static function, but can be used, not generated by script*/
PROVIDE ( calc_rtc_memory_crc = 0x40008170 );
PROVIDE ( calloc = 0x4000bee4 );
PROVIDE ( __clear_cache = 0x40063860 );
PROVIDE ( _close_r = 0x4000bd3c );
PROVIDE ( co_default_bdaddr = 0x3ffae704 );
PROVIDE ( co_null_bdaddr = 0x3ffb80e0 );
PROVIDE ( co_sca2ppm = 0x3ff971e8 );
Expand All @@ -45,8 +43,6 @@ PROVIDE ( crc32_be = 0x4005d024 );
PROVIDE ( crc32_le = 0x4005cfec );
PROVIDE ( crc8_be = 0x4005d114 );
PROVIDE ( crc8_le = 0x4005d0e0 );
PROVIDE ( _ctype_ = 0x3ff96354 );
PROVIDE ( __ctype_ptr__ = 0x3ff96350 );
PROVIDE ( _data_end_rom = 0x4000d5c8 );
PROVIDE ( _data_end_btdm_rom = 0x4000d4f8 );
PROVIDE ( _data_start_rom = 0x4000d4f8 );
Expand All @@ -55,7 +51,6 @@ PROVIDE ( _data_start_btdm = 0x3ffae6e0);
PROVIDE ( _data_end_btdm = 0x3ffaff10);
PROVIDE ( _bss_start_btdm = 0x3ffb8000);
PROVIDE ( _bss_end_btdm = 0x3ffbff70);
PROVIDE ( _daylight = 0x3ffae0a4 );
PROVIDE ( dbg_default_handler = 0x3ff97218 );
PROVIDE ( dbg_default_state = 0x3ff97220 );
PROVIDE ( dbg_state = 0x3ffb8d5d );
Expand Down Expand Up @@ -84,22 +79,16 @@ PROVIDE ( g_rom_spiflash_dummy_len_plus = 0x3ffae290 );
PROVIDE ( ecc_env = 0x3ffb8d60 );
PROVIDE ( ecc_Jacobian_InfinityPoint256 = 0x3ff972e8 );
PROVIDE ( em_buf_env = 0x3ffb8d74 );
PROVIDE ( environ = 0x3ffae0b4 );
PROVIDE ( esp_crc8 = 0x4005d144 );
PROVIDE ( _etext = 0x4000d66c );
PROVIDE ( ets_readySet_ = 0x3ffe01f0 );
PROVIDE ( ets_startup_callback = 0x3ffe0404 );
PROVIDE ( rwip_coex_cfg = 0x3ff9914c );
PROVIDE ( rwip_priority = 0x3ff99159 );
PROVIDE ( exc_cause_table = 0x3ff991d0 );
PROVIDE ( _exit_r = 0x4000bd28 );
PROVIDE ( free = 0x4000beb8 );
PROVIDE ( _fstat_r = 0x4000bccc );
PROVIDE ( __gcc_bcmp = 0x40064a70 );
PROVIDE ( GF_Jacobian_Point_Addition256 = 0x400163a4 );
PROVIDE ( GF_Jacobian_Point_Double256 = 0x40016260 );
PROVIDE ( GF_Point_Jacobian_To_Affine256 = 0x40016b0c );
PROVIDE ( _global_impure_ptr = 0x3ffae0b0 );
PROVIDE ( g_phyFuns_instance = 0x3ffae0c4 );
PROVIDE ( g_rom_flashchip = 0x3ffae270 );
PROVIDE ( gTxMsg = 0x3ffe0050 );
Expand Down Expand Up @@ -140,7 +129,6 @@ PROVIDE ( ld_env = 0x3ffb9510 );
PROVIDE ( ld_pcm_settings_dft = 0x3ff98a0c );
PROVIDE ( ld_sched_params = 0x3ffb96c0 );
PROVIDE ( ld_sync_train_channels = 0x3ff98a3c );
PROVIDE ( _link_r = 0x4000bc9c );
PROVIDE ( llc_default_handler = 0x3ff98b3c );
PROVIDE ( llc_default_state_tab_p_get = 0x40046058 );
PROVIDE ( llc_env = 0x3ffb96d0 );
Expand Down Expand Up @@ -184,12 +172,8 @@ PROVIDE ( lm_n_page_tab = 0x3ff990e8 );
PROVIDE ( lmp_desc_tab = 0x3ff96e6c );
PROVIDE ( lmp_ext_desc_tab = 0x3ff96d9c );
PROVIDE ( lm_state = 0x3ffb9a1c );
PROVIDE ( _lseek_r = 0x4000bd8c );
PROVIDE ( malloc = 0x4000bea0 );
PROVIDE ( maxSecretKey_256 = 0x3ff97448 );
PROVIDE ( __mb_cur_max = 0x3ff96530 );
PROVIDE ( mmu_init = 0x400095a4 );
PROVIDE ( __month_lengths = 0x3ff9609c );
PROVIDE ( MultiplyBigHexByUint32_256 = 0x40016214 );
PROVIDE ( MultiplyBigHexModP256 = 0x400160b8 );
PROVIDE ( MultiplyByU32ModP256 = 0x40015fdc );
Expand All @@ -199,7 +183,6 @@ PROVIDE ( mz_crc32 = 0x4005ee88 );
PROVIDE ( mz_free = 0x4005eed4 );
PROVIDE ( notEqual256 = 0x40015b04 );
PROVIDE ( one_bits = 0x3ff971f8 );
PROVIDE ( _open_r = 0x4000bd54 );
PROVIDE ( phy_get_romfuncs = 0x40004100 );
PROVIDE ( _Pri_4_HandlerAddress = 0x3ffe0648 );
PROVIDE ( _Pri_5_HandlerAddress = 0x3ffe064c );
Expand Down Expand Up @@ -248,7 +231,6 @@ PROVIDE ( lm_n192_mod_add = 0x40011e9c );
PROVIDE ( lm_n192_mod_sub = 0x40011eec );
PROVIDE ( r_ea_alarm_clear = 0x40015ab4 );
PROVIDE ( r_ea_alarm_set = 0x40015a10 );
PROVIDE ( _read_r = 0x4000bda8 );
PROVIDE ( r_ea_elt_cancel = 0x400150d0 );
PROVIDE ( r_ea_elt_create = 0x40015264 );
PROVIDE ( r_ea_elt_insert = 0x400152a8 );
Expand All @@ -262,7 +244,6 @@ PROVIDE ( r_ea_interval_insert = 0x4001557c );
PROVIDE ( r_ea_interval_remove = 0x40015590 );
PROVIDE ( ea_conflict_check = 0x40014e9c );
PROVIDE ( ea_prog_timer = 0x40014f88 );
PROVIDE ( realloc = 0x4000becc );
PROVIDE ( r_ea_offset_req = 0x40015748 );
PROVIDE ( r_ea_sleep_check = 0x40015928 );
PROVIDE ( r_ea_sw_isr = 0x40015724 );
Expand All @@ -281,7 +262,6 @@ PROVIDE ( r_em_buf_rx_buff_addr_get = 0x400173e8 );
PROVIDE ( r_em_buf_rx_free = 0x400173c4 );
PROVIDE ( r_em_buf_tx_buff_addr_get = 0x40017404 );
PROVIDE ( r_em_buf_tx_free = 0x4001741c );
PROVIDE ( _rename_r = 0x4000bc28 );
PROVIDE ( r_F1_256 = 0x400133e4 );
PROVIDE ( r_F2_256 = 0x40013568 );
PROVIDE ( r_F3_256 = 0x40013664 );
Expand Down Expand Up @@ -1290,9 +1270,6 @@ PROVIDE ( rwip_priority = 0x3ff99159 );
PROVIDE ( rwip_rf = 0x3ffbdb28 );
PROVIDE ( rwip_rf_p_get = 0x400558f4 );
PROVIDE ( r_XorKey = 0x400112c0 );
PROVIDE ( __sf_fake_stderr = 0x3ff96458 );
PROVIDE ( __sf_fake_stdin = 0x3ff96498 );
PROVIDE ( __sf_fake_stdout = 0x3ff96478 );
PROVIDE ( sha_blk_bits = 0x3ff99290 );
PROVIDE ( sha_blk_bits_bytes = 0x3ff99288 );
PROVIDE ( sha_blk_hash_bytes = 0x3ff9928c );
Expand Down Expand Up @@ -1348,17 +1325,12 @@ PROVIDE ( tdefl_get_prev_return_status = 0x400608d0 );
PROVIDE ( tdefl_init = 0x40060810 );
PROVIDE ( tdefl_write_image_to_png_file_in_memory = 0x4006091c );
PROVIDE ( tdefl_write_image_to_png_file_in_memory_ex = 0x40060910 );
PROVIDE ( _timezone = 0x3ffae0a0 );
PROVIDE ( tinfl_decompress = 0x4005ef30 );
PROVIDE ( tinfl_decompress_mem_to_callback = 0x40060090 );
PROVIDE ( tinfl_decompress_mem_to_mem = 0x40060050 );
PROVIDE ( _tzname = 0x3ffae030 );
PROVIDE ( UartDev = 0x3ffe019c );
PROVIDE ( _unlink_r = 0x4000bc84 );
PROVIDE ( user_code_start = 0x3ffe0400 );
PROVIDE ( veryBigHexP256 = 0x3ff9736c );
PROVIDE ( __wctomb = 0x3ff96540 );
PROVIDE ( _write_r = 0x4000bd70 );
PROVIDE ( xthal_bcopy = 0x4000c098 );
PROVIDE ( xthal_copy123 = 0x4000c124 );
PROVIDE ( xthal_get_ccompare = 0x4000c078 );
Expand Down
7 changes: 7 additions & 0 deletions components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* Unlike other ROM functions which are exported using PROVIDE, which declares
weak symbols, these libgcc functions are exported using assignment,
which declares strong symbols. This is done so that ROM functions are always
used instead of the ones provided by libgcc.a.
*/

__absvdi2 = 0x4006387c;
__absvsi2 = 0x40063868;
__adddf3 = 0x40002590;
Expand Down Expand Up @@ -41,6 +47,7 @@ __floatundidf = 0x4000c978;
__floatundisf = 0x4000c8b0;
__floatunsidf = 0x4000c938;
__floatunsisf = 0x4000c864;
__gcc_bcmp = 0x40064a70;
__gedf2 = 0x40063768;
__gesf2 = 0x4006340c;
__gtdf2 = 0x400636dc;
Expand Down
100 changes: 0 additions & 100 deletions components/esp_rom/esp32/ld/esp32.rom.nanofmt.ld

This file was deleted.

23 changes: 23 additions & 0 deletions components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* These are the .bss/.data symbols used by newlib functions present in ESP32 ROM.
See also esp32.rom.newlib-funcs.ld for the list of general newlib functions,
and esp32.rom.newlib-nano.ld for "nano" versions of printf/scanf family of functions.

Unlike other ROM functions and data which are exported using PROVIDE, which declares
weak symbols, newlib related functions are exported using assignment,
which declares strong symbols. This is done so that ROM functions are always
used instead of the ones provided by libc.a.
*/

_ctype_ = 0x3ff96354;
__ctype_ptr__ = 0x3ff96350;
_daylight = 0x3ffae0a4;
environ = 0x3ffae0b4;
_global_impure_ptr = 0x3ffae0b0;
__mb_cur_max = 0x3ff96530;
__month_lengths = 0x3ff9609c;
__sf_fake_stderr = 0x3ff96458;
__sf_fake_stdin = 0x3ff96498;
__sf_fake_stdout = 0x3ff96478;
_timezone = 0x3ffae0a0;
_tzname = 0x3ffae030;
__wctomb = 0x3ff96540;
Loading

0 comments on commit 70eda3d

Please sign in to comment.