Merge branch 'bugfix/linux_taret_fixes' into 'master'

linux target: various minor fixes

See merge request espressif/esp-idf!16905
This commit is contained in:
Ivan Grokhotkov 2022-01-25 08:43:38 +00:00
commit 0ebf93c01e
9 changed files with 84 additions and 8 deletions

View File

@ -113,6 +113,7 @@
/components/idf_test/ @esp-idf-codeowners/ci
/components/ieee802154/ @esp-idf-codeowners/ieee802154
/components/json/ @esp-idf-codeowners/app-utilities
/components/linux/ @esp-idf-codeowners/system
/components/log/ @esp-idf-codeowners/system
/components/lwip/ @esp-idf-codeowners/lwip
/components/mbedtls/ @esp-idf-codeowners/app-utilities @esp-idf-codeowners/security

View File

@ -196,6 +196,12 @@ endif()
list(APPEND link_options "-fno-lto")
if(CONFIG_IDF_TARGET_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
list(APPEND link_options "-Wl,-dead_strip")
else()
list(APPEND link_options "-Wl,--gc-sections")
endif()
# Placing jump tables in flash would cause issues with code that required
# to be placed in IRAM
list(APPEND compile_options "-fno-jump-tables")

View File

@ -37,6 +37,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
string
default "$IDF_TARGET"
config IDF_TARGET_LINUX
bool
default "y" if IDF_TARGET="linux"
config IDF_TARGET_ESP32
bool
default "y" if IDF_TARGET="esp32"
@ -163,6 +167,7 @@ mainmenu "Espressif IoT Development Framework Configuration"
config APP_BUILD_TYPE_APP_2NDBOOT
bool
prompt "Default (binary application + 2nd stage bootloader)"
depends on !IDF_TARGET_LINUX
select APP_BUILD_GENERATE_BINARIES
select APP_BUILD_BOOTLOADER
select APP_BUILD_USE_FLASH_SECTIONS

View File

@ -147,9 +147,14 @@ FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a = a << b; return a; }
//
// Using unique sections also means --gc-sections can remove unused
// data with a custom section type set
#ifndef CONFIG_IDF_TARGET_LINUX
#define _SECTION_ATTR_IMPL(SECTION, COUNTER) __attribute__((section(SECTION "." _COUNTER_STRINGIFY(COUNTER))))
#define _COUNTER_STRINGIFY(COUNTER) #COUNTER
#else
// Custom section attributes are generally not used in the port files for Linux target, but may be found
// in the common header files. Don't declare custom sections in that case.
#define _SECTION_ATTR_IMPL(SECTION, COUNTER)
#endif
/* Use IDF_DEPRECATED attribute to mark anything deprecated from use in
ESP-IDF's own source code, but not deprecated for external users.

View File

@ -48,8 +48,11 @@ endfunction()
if(target STREQUAL "linux")
# We need to disable some warnings due to the ROM code's printf implementation
if(${CMAKE_CXX_COMPILER_VERSION} GREATER "7.0.0") # TODO: clang compatibility
target_compile_options(${COMPONENT_LIB} PUBLIC -Wimplicit-fallthrough=0 -Wno-shift-count-overflow)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} GREATER "7.0.0")
target_compile_options(${COMPONENT_LIB} PRIVATE -Wimplicit-fallthrough=0 -Wno-shift-count-overflow)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang") # Clang or AppleClang
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-integer-overflow -Wno-shift-count-overflow)
endif()
else()
target_linker_script(${COMPONENT_LIB} INTERFACE "${target}/${ld_folder}/${target}.rom.ld")

View File

@ -0,0 +1,47 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __SYS_LOCK_H__
#define __SYS_LOCK_H__
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* newlib locks implementation for CONFIG_IDF_TARGET_LINUX, single threaded.
* Note, currently this doesn't implement the functions required
* when _RETARGETABLE_LOCKING is defined. They should be added.
*/
/* Compatibility definitions for legacy newlib locking functions */
typedef int _lock_t;
static inline void _lock_init(_lock_t *plock) {}
static inline void _lock_init_recursive(_lock_t *plock) {}
static inline void _lock_close(_lock_t *plock) {}
static inline void _lock_close_recursive(_lock_t *plock) {}
static inline void _lock_acquire(_lock_t *plock) {}
static inline void _lock_acquire_recursive(_lock_t *plock) {}
static inline int _lock_try_acquire(_lock_t *plock)
{
return 1;
}
static inline int _lock_try_acquire_recursive(_lock_t *plock)
{
return 1;
}
static inline void _lock_release(_lock_t *plock) {}
static inline void _lock_release_recursive(_lock_t *plock) {}
#ifdef __cplusplus
}
#endif
#endif /* __SYS_LOCK_H__ */

View File

@ -1 +1,7 @@
#include "bsd/sys/queue.h"
#if __has_include(<bsd/sys/queue.h>)
/* On Linux, try using sys/queue.h provided by libbsd-dev */
#include <bsd/sys/queue.h>
#else
/* Fall back to sys/queue.h which may exist e.g. on macOS */
#include_next <sys/queue.h>
#endif

View File

@ -1,4 +1,10 @@
idf_component_register(PRIV_REQUIRES esptool_py)
idf_build_get_property(target IDF_TARGET)
set(priv_req)
if(NOT ${target} STREQUAL "linux")
list(APPEND priv_req esptool_py)
endif()
idf_component_register(PRIV_REQUIRES ${priv_req})
if(BOOTLOADER_BUILD)
return()

View File

@ -111,13 +111,10 @@ function(__build_set_default_build_specifications)
list(APPEND cxx_compile_options "-std=gnu++11")
list(APPEND link_options "-Wl,--gc-sections")
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND)
endfunction()
#