]> granicus.if.org Git - esp-idf/commitdiff
newlib: force including IDF locks implementation
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 18 Mar 2019 03:47:00 +0000 (11:47 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Wed, 10 Apr 2019 05:52:30 +0000 (13:52 +0800)
components/newlib/CMakeLists.txt
components/newlib/component.mk
components/newlib/locks.c

index 76645b33ff2359faed15716373564b2aac4013c0..6cb6fb8e51d5df53820b55a464d7fe659ccfe518 100644 (file)
@@ -25,6 +25,10 @@ if(GCC_NOT_5_2_0)
         set(COMPONENT_ADD_LDFRAGMENTS esp32-spiram-rom-functions-c.lf)
     endif()
 
+    # Forces the linker to include locks.o from this component, which
+    # replaces weak locking functions defined in libc.a:locks.o
+    set(EXTRA_LINK_FLAGS "-u newlib_include_locks_impl")
+
 else()
     # Remove this section when GCC 5.2.0 is no longer supported
     # 'include' and 'lib' directories should also be removed.
@@ -58,3 +62,7 @@ endif()
 target_link_libraries(${COMPONENT_TARGET} ${LIBC} ${LIBM})
 
 set_source_files_properties(syscalls.c PROPERTIES COMPILE_FLAGS -fno-builtin)
+
+if(EXTRA_LINK_FLAGS)
+    target_link_libraries(${COMPONENT_TARGET} "${EXTRA_LINK_FLAGS}")
+endif()
index be7e730e83890d79072e7d183f5e23e09434c33b..008497acef36f3953fd945f17c5c7790d93faf8b 100644 (file)
@@ -14,6 +14,10 @@ ifdef CONFIG_SPIRAM_CACHE_WORKAROUND
 COMPONENT_ADD_LDFRAGMENTS := esp32-spiram-rom-functions-c.lf
 endif
 
+# Forces the linker to include locks.o from this component, which
+# replaces weak locking functions defined in libc.a:locks.o
+COMPONENT_ADD_LDFLAGS += -u newlib_include_locks_impl
+
 else # GCC_NOT_5_2_0
 # Remove this section when GCC 5.2.0 is no longer supported
 
index 708ddab3f00f7235e8df8ec3e22506589e7171c2..9efaf51f3e0ef3b663a78882cf0d20adc0282197 100644 (file)
@@ -216,3 +216,10 @@ void IRAM_ATTR _lock_release(_lock_t *lock) {
 void IRAM_ATTR _lock_release_recursive(_lock_t *lock) {
     lock_release_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
 }
+
+/* No-op function, used to force linking this file,
+   instead of the dummy locks implementation from newlib.
+ */
+void newlib_include_locks_impl()
+{
+}