Merge branch 'bugfix/macos_build_linux_target_misc' into 'master'

Misc fixes for IDF_TARGET=linux on macOS host

See merge request espressif/esp-idf!28015
This commit is contained in:
Ivan Grokhotkov 2023-12-21 17:55:24 +08:00
commit 7265febc31
7 changed files with 41 additions and 19 deletions

View File

@ -121,8 +121,10 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND compile_options "-Wno-c2x-extensions") list(APPEND compile_options "-Wno-c2x-extensions")
# warning on xMPU_SETTINGS for esp32s2 has size 0 for C and 1 for C++ # warning on xMPU_SETTINGS for esp32s2 has size 0 for C and 1 for C++
list(APPEND compile_options "-Wno-extern-c-compat") list(APPEND compile_options "-Wno-extern-c-compat")
# warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 if(NOT (CONFIG_IDF_TARGET_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin"))
list(APPEND compile_options "-Wno-single-bit-bitfield-constant-conversion") # warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1
list(APPEND compile_options "-Wno-single-bit-bitfield-constant-conversion")
endif()
endif() endif()
# More warnings may exist in unit tests and example projects. # More warnings may exist in unit tests and example projects.

View File

@ -1,5 +1,3 @@
idf_build_get_property(target IDF_TARGET)
set(srcs_lwip set(srcs_lwip
"lwip/esp_netif_lwip.c" "lwip/esp_netif_lwip.c"
"lwip/esp_netif_sntp.c" "lwip/esp_netif_sntp.c"
@ -17,12 +15,6 @@ set(srcs
set(include_dirs "include") set(include_dirs "include")
set(priv_include_dirs "private_include") set(priv_include_dirs "private_include")
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
list(APPEND include_dirs
"linux/stubs/include")
endif()
if(CONFIG_PPP_SUPPORT) if(CONFIG_PPP_SUPPORT)
list(APPEND srcs_lwip lwip/esp_netif_lwip_ppp.c lwip/netif/ppp.c) list(APPEND srcs_lwip lwip/esp_netif_lwip_ppp.c lwip/netif/ppp.c)
endif() endif()

View File

@ -1,8 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include_next <endian.h>

View File

@ -4,7 +4,7 @@ if(NOT "${target}" STREQUAL "linux")
endif() endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
list(APPEND srcs getrandom.c) list(APPEND srcs getrandom.c assert_func.c)
endif() endif()
idf_component_register(INCLUDE_DIRS include idf_component_register(INCLUDE_DIRS include

View File

@ -0,0 +1,23 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include "hal/assert.h"
// Implementation of __assert_func for macOS.
void __assert_func(const char *file, int line, const char *func, const char *expr)
{
fprintf(stderr, "assert failed at %s:%d (%s): %s\n", file, line, func, expr);
abort();
}
// Defining this symbol as well, since `hal` component will add "-U __assert_func" linker option,
// and symbols are prefixed with an additional underscore on macOS.
// (Can't use __attribute__((alias)) because aliases are not supported on macOS.)
void _assert_func(const char *file, int line, const char *func, const char *expr)
{
__assert_func(file, line, func, expr);
}

View File

@ -0,0 +1,11 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#if __APPLE__
#include_next <machine/endian.h>
#else
#include <endian.h>
#endif

View File

@ -71,7 +71,9 @@ endif()
append_line(" */") append_line(" */")
append_line(".data") append_line(".data")
append_line("#if !defined (__APPLE__) && !defined (__linux__)")
append_line(".section .rodata.embedded") append_line(".section .rodata.embedded")
append_line("#endif")
make_and_append_identifier("${varname}") make_and_append_identifier("${varname}")
make_and_append_identifier("_binary_${varname}_start" "for objcopy compatibility") make_and_append_identifier("_binary_${varname}_start" "for objcopy compatibility")
append("${data}") append("${data}")