[3/3] Add '--oslib=' option when default C library is picolibc
Commit Message
This option allows targets to insert an OS library after the C library
in the LIB_PATH spec file fragment. This library maps a few POSIX APIs
used by picolibc to underlying system capabilities.
For example, picolibc provides 'libsemihost' on various targets which
maps these APIs to semihosting capabilities. This would be used with
this option by specifying --oslib=semihost
Signed-off-by: Keith Packard <keithp@keithp.com>
---
gcc/config.gcc | 7 +++++++
gcc/config/picolibc.h | 32 ++++++++++++++++++++++++++++++++
gcc/config/picolibc.opt | 26 ++++++++++++++++++++++++++
3 files changed, 65 insertions(+)
create mode 100644 gcc/config/picolibc.h
create mode 100644 gcc/config/picolibc.opt
@@ -5903,3 +5903,10 @@ case "$default_libc" in
tm_defines="$tm_defines DEFAULT_LIBC=$default_libc"
;;
esac
+
+case "$default_libc" in
+ LIBC_PICOLIBC)
+ extra_options="${extra_options} picolibc.opt"
+ tm_file="${tm_file} picolibc.h"
+ ;;
+esac
new file mode 100644
@@ -0,0 +1,32 @@
+/* Configuration common to all targets running Picolibc.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#undef LIB_SPEC
+#define LIB_SPEC "--start-group -lc %{-oslib=*:-l%*} %(libgcc) --end-group"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "crt0%O%s"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC ""
new file mode 100644
@@ -0,0 +1,26 @@
+; Processor-independent options for picolibc.
+;
+; Copyright (C) 2022 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3. If not see
+; <http://www.gnu.org/licenses/>.
+
+-oslib
+Driver Separate Alias(-oslib=)
+
+-oslib=
+Driver Joined
+Specify an OS support library to load after libc.