From: Alexey Lapshin <alexey.lapshin@espressif.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Alexey Gerenkov <alexey.gerenkov@espressif.com>,
Ivan Grokhotkov <ivan@espressif.com>,
"jcmvbkbc@gmail.com" <jcmvbkbc@gmail.com>
Subject: [PATCH v2 1/2] gcc: xtensa: add mdynconfig option
Date: Mon, 1 Apr 2024 12:16:37 +0000 [thread overview]
Message-ID: <67280210800347ca0dc716816159e79d402676d1.camel@espressif.com> (raw)
In-Reply-To: <485a6a6c62a8632d9e3ac44b2d8fd935c0e0a78b.camel@espressif.com>
gcc/
* config/xtensa/elf.h (ASM_SPEC, LINK_SPEC): Pass dynconfig to
assembler/linker.
* config/xtensa/linux.h (ASM_SPEC, LINK_SPEC): Likewise.
* config/xtensa/uclinux.h (ASM_SPEC, LINK_SPEC): Likewise.
* config/xtensa/xtensa-dynconfig.cc: May build dynconfig path with
dir in XTENSA_GNU_CONFIG and filename in mdynconfig option.
* doc/invoke.texi: Add XTENSA_GNU_CONFIG and mdynconfig doc.
---
gcc/config/xtensa/elf.h | 6 ++-
gcc/config/xtensa/linux.h | 6 ++-
gcc/config/xtensa/uclinux.h | 6 ++-
gcc/config/xtensa/xtensa-dynconfig.cc | 55 ++++++++++++++++++++++++++-
gcc/config/xtensa/xtensa.opt | 4 ++
gcc/doc/invoke.texi | 14 +++++++
6 files changed, 83 insertions(+), 8 deletions(-)
diff --git a/gcc/config/xtensa/elf.h b/gcc/config/xtensa/elf.h
index aa14f9d0134..dd20cb310d0 100644
--- a/gcc/config/xtensa/elf.h
+++ b/gcc/config/xtensa/elf.h
@@ -49,7 +49,8 @@ along with GCC; see the file COPYING3. If not see
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LIB_SPEC
#define LIB_SPEC "-lc -lsim -lc -lhandlers-sim -lhal"
@@ -69,7 +70,8 @@ along with GCC; see the file COPYING3. If not see
%{rdynamic:-export-dynamic} \
%{static:-static}}} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."
diff --git a/gcc/config/xtensa/linux.h b/gcc/config/xtensa/linux.h
index 03ec8e7254a..5a19af13dd3 100644
--- a/gcc/config/xtensa/linux.h
+++ b/gcc/config/xtensa/linux.h
@@ -46,7 +46,8 @@ along with GCC; see the file COPYING3. If not see
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
@@ -60,7 +61,8 @@ along with GCC; see the file COPYING3. If not see
%{static-pie:-static -pie --no-dynamic-linker -z text} \
%{static:-static}} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."
diff --git a/gcc/config/xtensa/uclinux.h b/gcc/config/xtensa/uclinux.h
index 062e9640d64..7dd868e074a 100644
--- a/gcc/config/xtensa/uclinux.h
+++ b/gcc/config/xtensa/uclinux.h
@@ -53,13 +53,15 @@ along with GCC; see the file COPYING3. If not see
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LINK_SPEC
#define LINK_SPEC \
"%{!no-elf2flt:%{!elf2flt*:-elf2flt}} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."
diff --git a/gcc/config/xtensa/xtensa-dynconfig.cc b/gcc/config/xtensa/xtensa-dynconfig.cc
index 3bd2760e4d8..fe2559e1ed7 100644
--- a/gcc/config/xtensa/xtensa-dynconfig.cc
+++ b/gcc/config/xtensa/xtensa-dynconfig.cc
@@ -22,6 +22,7 @@
#include "coretypes.h"
#include "diagnostic.h"
#include "intl.h"
+#include "options.h"
#define XTENSA_CONFIG_DEFINITION
#include "xtensa-config.h"
#include "xtensa-dynconfig.h"
@@ -67,6 +68,55 @@ dlerror (void)
#define CONFIG_ENV_NAME "XTENSA_GNU_CONFIG"
+#ifdef ENABLE_PLUGIN
+
+static char *get_xtensa_dynconfig_file (void)
+{
+ const char *xtensa_dynconfig_env = getenv (CONFIG_ENV_NAME);
+ if (!strlen (xtensa_dynconfig_file))
+ {
+ if (xtensa_dynconfig_env && !strlen (lbasename (xtensa_dynconfig_env)))
+ {
+ /* XTENSA_GNU_CONFIG has directory path, but dynconfig file is not set */
+ return NULL;
+ }
+ else if (xtensa_dynconfig_env)
+ {
+ /* XTENSA_GNU_CONFIG has filepath */
+ return xstrdup (xtensa_dynconfig_env);
+ }
+ /* dynconfig is not set */
+ return NULL;
+ }
+ if (!xtensa_dynconfig_env)
+ {
+ /* XTENSA_GNU_CONFIG has filepath */
+ return xstrdup (xtensa_dynconfig_file);
+ }
+ if (!strlen (lbasename (xtensa_dynconfig_env)))
+ {
+ /* XTENSA_GNU_CONFIG has directory path and dynconfig file is set */
+ const size_t len = strlen (xtensa_dynconfig_env) +
+ strlen (xtensa_dynconfig_file) + 1;
+ char *path = ( char *) xmalloc (len);
+ strcpy (path, xtensa_dynconfig_env);
+ strcat (path, xtensa_dynconfig_file);
+ return path;
+ }
+ if (strcmp (lbasename (xtensa_dynconfig_env),
+ lbasename (xtensa_dynconfig_file)))
+ {
+ fatal_error (input_location,
+ "Both %qs and \"-dynconfig=\" specified but pointed different files: \"%qs\" \"%qs\"",
+ CONFIG_ENV_NAME, xtensa_dynconfig_env, xtensa_dynconfig_file);
+ exit (FATAL_EXIT_CODE);
+ }
+ /* XTENSA_GNU_CONFIG and mdynconfig option point to the same file */
+ return xstrdup (xtensa_dynconfig_env);
+}
+
+#endif /* ENABLE_PLUGIN */
+
const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
const void *no_plugin_def,
const void *no_name_def ATTRIBUTE_UNUSED)
@@ -78,12 +128,13 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
if (!init)
{
- const char *path = getenv (CONFIG_ENV_NAME);
+ char *path = get_xtensa_dynconfig_file();
init = 1;
if (!path)
return no_plugin_def;
handle = dlopen (path, RTLD_LAZY);
+ free (path);
if (!handle)
{
fatal_error (input_location,
@@ -119,7 +170,7 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
#else
if (!init)
{
- const char *path = getenv (CONFIG_ENV_NAME);
+ const char *path = strcmp(xtensa_dynconfig_file, "") ? xtensa_dynconfig_file : getenv (CONFIG_ENV_NAME);
init = 1;
if (path)
diff --git a/gcc/config/xtensa/xtensa.opt b/gcc/config/xtensa/xtensa.opt
index b653e99d189..0f073791cc3 100644
--- a/gcc/config/xtensa/xtensa.opt
+++ b/gcc/config/xtensa/xtensa.opt
@@ -71,3 +71,7 @@ Use windowed registers ABI.
mstrict-align
Target Var(xtensa_strict_alignment) Init(XTENSA_STRICT_ALIGNMENT_UNDEFINED)
Do not use unaligned memory references.
+
+mdynconfig=
+Target RejectNegative Joined Var(xtensa_dynconfig_file) Init("")
+Directory or path to dynconfig library.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 942103c23f5..153db7853de 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -36329,6 +36329,14 @@ Choose startup files and linker script suitable for the simulator.
These options are supported for Xtensa targets:
@table @gcctabopt
+
+@vindex XTENSA_GNU_CONFIG
+@item XTENSA_GNU_CONFIG
+@env{XTENSA_GNU_CONFIG} is designed to set dir/fullpath to dynconfig
+library. In case directory is present in @env{XTENSA_GNU_CONFIG}
+filename of dynconfig library must be set in @option{-mdynconfig}.
+Must ends with directory separator in case contains direcrory path.
+
@opindex mconst16
@opindex mno-const16
@item -mconst16
@@ -36476,6 +36484,12 @@ The default is @option{-mno-strict-align} for cores that support both
unaligned loads and stores in hardware and @option{-mstrict-align} for all
other cores.
+@opindex mdynconfig
+@item -mdynconfig=@var{path}
+Set the filename/path to xtensa dynconfig.
+In case filename is set the directory part must be present in
+@env{XTENSA_GNU_CONFIG} environment variable.
+
@end table
@node zSeries Options
--
2.34.1
next prev parent reply other threads:[~2024-04-01 12:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 14:34 [PATCH 0/3] Espressif xtensa chips multilib Alexey Lapshin
2023-07-20 14:35 ` [PATCH 1/3] gcc: xtensa: add mdynconfig option Alexey Lapshin
2023-07-20 14:37 ` [PATCH 2/3] gcc: xtensa: use dynconfig settings as builtin-macros Alexey Lapshin
2023-07-20 15:04 ` Max Filippov
2023-07-20 15:12 ` Alexey Lapshin
2023-07-20 15:25 ` Max Filippov
2023-07-20 16:10 ` Alexey Lapshin
2023-07-20 17:43 ` Max Filippov
2023-07-20 17:52 ` Alexey Lapshin
2023-07-20 17:54 ` Alexey Lapshin
2023-07-20 17:58 ` Max Filippov
2023-07-20 17:45 ` Alexey Lapshin
2023-07-20 17:55 ` Max Filippov
2023-07-20 14:37 ` [PATCH 3/3] gcc: xtensa: add xtensa*-esp*-elf multilib Alexey Lapshin
2023-12-11 7:35 ` [PATCH 0/3] Espressif xtensa chips multilib Alexey Lapshin
2024-04-01 12:16 ` Alexey Lapshin [this message]
2024-04-01 12:16 ` [PATCH v2 2/2] gcc: xtensa: add xtensa*-esp*-elf multilib Alexey Lapshin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67280210800347ca0dc716816159e79d402676d1.camel@espressif.com \
--to=alexey.lapshin@espressif.com \
--cc=alexey.gerenkov@espressif.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ivan@espressif.com \
--cc=jcmvbkbc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).