]> granicus.if.org Git - esp-idf/commitdiff
newlib: when compiling with GCC8, use newlib headers and libraries from toolchain
authorIvan Grokhotkov <ivan@espressif.com>
Fri, 8 Mar 2019 07:07:50 +0000 (15:07 +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/esp32-spiram-rom-functions-c.lf [new file with mode: 0644]
components/newlib/esp32-spiram-rom-functions-psram-workaround.lf [moved from components/newlib/esp32-spiram-rom-functions.lf with 96% similarity]

index c6eed1a19ec9a0358c1517cc19ff5ac425a873f4..76645b33ff2359faed15716373564b2aac4013c0 100644 (file)
@@ -9,15 +9,10 @@ set(COMPONENT_SRCS "locks.c"
                    "termios.c"
                    "utime.c"
                    "time.c")
-set(COMPONENT_ADD_INCLUDEDIRS platform_include include)
+set(COMPONENT_ADD_INCLUDEDIRS platform_include)
 
-if(CONFIG_SPIRAM_CACHE_WORKAROUND)
-    set(LIBC c-psram-workaround)
-    set(LIBM m-psram-workaround)
-
-    set(COMPONENT_ADD_LDFRAGMENTS esp32-spiram-rom-functions.lf)
-else()
 
+if(GCC_NOT_5_2_0)
     if(CONFIG_NEWLIB_NANO_FORMAT)
         set(LIBC c_nano)
     else()
@@ -25,13 +20,41 @@ else()
     endif()
 
     set(LIBM m)
-endif()
 
+    if(CONFIG_SPIRAM_CACHE_WORKAROUND)
+        set(COMPONENT_ADD_LDFRAGMENTS esp32-spiram-rom-functions-c.lf)
+    endif()
+
+else()
+    # Remove this section when GCC 5.2.0 is no longer supported
+    # 'include' and 'lib' directories should also be removed.
+    # An if statement about LIB_PATH below should also be removed.
+    list(APPEND COMPONENT_ADD_INCLUDEDIRS include)
+    set(LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
+
+    if(CONFIG_SPIRAM_CACHE_WORKAROUND)
+        set(LIBC c-psram-workaround)
+        set(LIBM m-psram-workaround)
+
+        set(COMPONENT_ADD_LDFRAGMENTS esp32-spiram-rom-functions-psram-workaround.lf)
+    else()
+
+        if(CONFIG_NEWLIB_NANO_FORMAT)
+            set(LIBC c_nano)
+        else()
+            set(LIBC c)
+        endif()
+
+        set(LIBM m)
+    endif()
+endif()
 set(COMPONENT_REQUIRES vfs)  # for sys/ioctl.h
 
 register_component()
 
-target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib")
+if (LIB_PATH)
+    target_link_libraries(${COMPONENT_TARGET} "-L ${LIB_PATH}")
+endif()
 target_link_libraries(${COMPONENT_TARGET} ${LIBC} ${LIBM})
 
 set_source_files_properties(syscalls.c PROPERTIES COMPILE_FLAGS -fno-builtin)
index 399af65263ef562f5f65a5ac4365ba15e990db1c..be7e730e83890d79072e7d183f5e23e09434c33b 100644 (file)
@@ -1,8 +1,26 @@
 
+ifeq ($(GCC_NOT_5_2_0), 1)
+
+ifdef CONFIG_NEWLIB_NANO_FORMAT
+LIBC := c_nano
+else  # CONFIG_NEWLIB_NANO_FORMAT
+LIBC := c
+endif  # CONFIG_NEWLIB_NANO_FORMAT
+
+COMPONENT_ADD_LDFLAGS := -l$(LIBC) -lm -lnewlib
+COMPONENT_ADD_INCLUDEDIRS := platform_include
+
+ifdef CONFIG_SPIRAM_CACHE_WORKAROUND
+COMPONENT_ADD_LDFRAGMENTS := esp32-spiram-rom-functions-c.lf
+endif
+
+else # GCC_NOT_5_2_0
+# Remove this section when GCC 5.2.0 is no longer supported
+
 ifdef CONFIG_SPIRAM_CACHE_WORKAROUND
 LIBC_PATH := $(COMPONENT_PATH)/lib/libc-psram-workaround.a
 LIBM_PATH := $(COMPONENT_PATH)/lib/libm-psram-workaround.a
-COMPONENT_ADD_LDFRAGMENTS := esp32-spiram-rom-functions.lf
+COMPONENT_ADD_LDFRAGMENTS := esp32-spiram-rom-functions-psram-workaround.lf
 else
 
 ifdef CONFIG_NEWLIB_NANO_FORMAT
@@ -20,5 +38,6 @@ COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(LIBM_PATH) -lnewlib
 COMPONENT_ADD_LINKER_DEPS := $(LIBC_PATH) $(LIBM_PATH)
 
 COMPONENT_ADD_INCLUDEDIRS := platform_include include
+endif  # GCC_NOT_5_2_0
 
 syscalls.o: CFLAGS += -fno-builtin
diff --git a/components/newlib/esp32-spiram-rom-functions-c.lf b/components/newlib/esp32-spiram-rom-functions-c.lf
new file mode 100644 (file)
index 0000000..cff6a68
--- /dev/null
@@ -0,0 +1,147 @@
+# If the Newlib functions in ROM aren't used (eg because the external SPI RAM workaround is active), these functions will 
+# be linked into the application directly instead. Normally, they would end up in flash, which is undesirable because esp-idf
+# and/or applications may assume that because these functions normally are in ROM, they are accessible even when flash is 
+# inaccessible. To work around this, this ld fragment places these functions in RAM instead. If the ROM functions are used,
+# these defines do nothing, so they can still be included in that situation.
+#
+#
+# Note: the only difference between esp32-spiram-rom-functions-c.lf
+# and esp32-spiram-rom-functions-psram-workaround.lf is the archive name.
+
+[mapping:libc]
+archive:
+  if NEWLIB_NANO_FORMAT = y:
+    libc_nano.a
+  else:
+    libc.a
+entries:
+  if SPIRAM_CACHE_WORKAROUND = y:
+    lib_a-utoa (noflash)
+    lib_a-longjmp (noflash)
+    lib_a-setjmp (noflash)
+    lib_a-abs (noflash)
+    lib_a-div (noflash)
+    lib_a-labs (noflash)
+    lib_a-ldiv (noflash)
+    lib_a-quorem (noflash)
+    lib_a-utoa (noflash)
+    lib_a-itoa (noflash)
+    lib_a-atoi (noflash)
+    lib_a-atol (noflash)
+    lib_a-strtol (noflash)
+    lib_a-strtoul (noflash)
+    lib_a-wcrtomb (noflash)
+    lib_a-fvwrite (noflash)
+    lib_a-wbuf (noflash)
+    lib_a-wsetup (noflash)
+    lib_a-fputwc (noflash)
+    lib_a-wctomb_r (noflash)
+    lib_a-ungetc (noflash)
+    lib_a-makebuf (noflash)
+    lib_a-fflush (noflash)
+    lib_a-refill (noflash)
+    lib_a-s_fpclassify (noflash)
+    lib_a-asctime (noflash)
+    lib_a-ctime (noflash)
+    lib_a-ctime_r (noflash)
+    lib_a-lcltime (noflash)
+    lib_a-lcltime_r (noflash)
+    lib_a-gmtime (noflash)
+    lib_a-gmtime_r (noflash)
+    lib_a-strftime (noflash)
+    lib_a-mktime (noflash)
+    lib_a-syswrite (noflash)
+    lib_a-tzset_r (noflash)
+    lib_a-tzset (noflash)
+    lib_a-toupper (noflash)
+    lib_a-tolower (noflash)
+    lib_a-toascii (noflash)
+    lib_a-systimes (noflash)
+    lib_a-time (noflash)
+    lib_a-gettzinfo (noflash)
+    lib_a-strupr (noflash)
+    lib_a-asctime_r (noflash)
+    lib_a-bzero (noflash)
+    lib_a-close (noflash)
+    lib_a-creat (noflash)
+    lib_a-environ (noflash)
+    lib_a-fclose (noflash)
+    lib_a-isalnum (noflash)
+    lib_a-isalpha (noflash)
+    lib_a-isascii (noflash)
+    lib_a-isblank (noflash)
+    lib_a-iscntrl (noflash)
+    lib_a-isdigit (noflash)
+    lib_a-isgraph (noflash)
+    lib_a-islower (noflash)
+    lib_a-isprint (noflash)
+    lib_a-ispunct (noflash)
+    lib_a-isspace (noflash)
+    lib_a-isupper (noflash)
+    lib_a-memccpy (noflash)
+    lib_a-memchr (noflash)
+    lib_a-memcmp (noflash)
+    lib_a-memcpy (noflash)
+    lib_a-memmove (noflash)
+    lib_a-memrchr (noflash)
+    lib_a-memset (noflash)
+    lib_a-open (noflash)
+    lib_a-rand (noflash)
+    lib_a-rand_r (noflash)
+    lib_a-read (noflash)
+    lib_a-rshift (noflash)
+    lib_a-sbrk (noflash)
+    lib_a-srand (noflash)
+    lib_a-strcasecmp (noflash)
+    lib_a-strcasestr (noflash)
+    lib_a-strcat (noflash)
+    lib_a-strchr (noflash)
+    lib_a-strcmp (noflash)
+    lib_a-strcoll (noflash)
+    lib_a-strcpy (noflash)
+    lib_a-strcspn (noflash)
+    lib_a-strdup (noflash)
+    lib_a-strlcat (noflash)
+    lib_a-strlcpy (noflash)
+    lib_a-strlen (noflash)
+    lib_a-strlwr (noflash)
+    lib_a-strncasecmp (noflash)
+    lib_a-strncat (noflash)
+    lib_a-strncmp (noflash)
+    lib_a-strncpy (noflash)
+    lib_a-strndup (noflash)
+    lib_a-strnlen (noflash)
+    lib_a-strrchr (noflash)
+    lib_a-strsep (noflash)
+    lib_a-strspn (noflash)
+    lib_a-strstr (noflash)
+    lib_a-strtok_r (noflash)
+    lib_a-strupr (noflash)
+    lib_a-stdio (noflash)
+    lib_a-syssbrk (noflash)
+    lib_a-sysclose (noflash)
+    lib_a-sysopen (noflash)
+    creat (noflash)
+    lib_a-sysread (noflash)
+    lib_a-syswrite (noflash)
+    lib_a-impure (noflash)
+    lib_a-tzvars (noflash)
+    lib_a-sf_nan (noflash)
+    lib_a-tzcalc_limits (noflash)
+    lib_a-month_lengths (noflash)
+    lib_a-timelocal (noflash)
+    lib_a-findfp (noflash)
+    lock (noflash)
+    lib_a-getenv_r (noflash)
+    isatty (noflash)
+    lib_a-fwalk (noflash)
+    lib_a-getenv_r (noflash)
+    lib_a-tzlock (noflash)
+    lib_a-ctype_ (noflash)
+    lib_a-sccl (noflash)
+    lib_a-strptime (noflash)
+    lib_a-envlock (noflash)
+    lib_a-raise (noflash)
+    lib_a-strdup_r (noflash)
+    lib_a-system (noflash)
+    lib_a-strndup_r (noflash)
similarity index 96%
rename from components/newlib/esp32-spiram-rom-functions.lf
rename to components/newlib/esp32-spiram-rom-functions-psram-workaround.lf
index 216fb05907903518b74b42b5fb0d99dd744fa43c..6dbc063007abc3a21579eb06245f14a353ed0660 100644 (file)
@@ -7,6 +7,9 @@
 #
 # Note: We currently never link libg-psram-workaround.a, so no rules
 # are generated for this library
+#
+# Note: the only difference between esp32-spiram-rom-functions-c.lf
+# and esp32-spiram-rom-functions-psram-workaround.lf is the archive name.
 
 [mapping:libc_psram_workaround]
 archive: libc-psram-workaround.a