[1/3] gcc: xtensa: add mdynconfig option
Checks
Commit Message
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(-)
--
2.34.1
@@ -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 "."
@@ -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 "."
@@ -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 "."
@@ -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)
@@ -64,3 +64,7 @@ Use call0 ABI.
mabi=windowed
Target RejectNegative Var(xtensa_windowed_abi, 1)
Use windowed registers ABI.
+
+mdynconfig=
+Target RejectNegative Joined Var(xtensa_dynconfig_file) Init("")
+Directory or path to dynconfig library.
@@ -34258,6 +34258,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
@@ -34394,6 +34402,12 @@ instructions, in clock cycles. This affects, when optimizing for speed,
whether loading a constant from literal pool using @code{L32R} or
synthesizing the constant from a small one with a couple of arithmetic
instructions. The default value is 0.
+
+@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