extra_options="${extra_options} darwin.opt"
c_target_objs="${c_target_objs} darwin-c.o"
cxx_target_objs="${cxx_target_objs} darwin-c.o"
+ d_target_objs="${d_target_objs} darwin-d.o"
fortran_target_objs="darwin-f.o"
target_has_targetcm=yes
+ target_has_targetdm=yes
extra_objs="${extra_objs} darwin.o"
extra_gcc_objs="darwin-driver.o"
default_use_cxa_atexit=yes
--- /dev/null
+/* Darwin support needed only by D front-end.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+
+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/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm_d.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for Darwin targets. */
+
+static void
+darwin_d_os_builtins (void)
+{
+ d_add_builtin_version ("Posix");
+ d_add_builtin_version ("OSX");
+ d_add_builtin_version ("darwin");
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS darwin_d_os_builtins
+
+/* Define TARGET_D_MINFO_SECTION for Darwin targets. */
+
+#undef TARGET_D_MINFO_SECTION
+#define TARGET_D_MINFO_SECTION "__DATA,__minfodata"
+
+#undef TARGET_D_MINFO_START_NAME
+#define TARGET_D_MINFO_START_NAME "*section$start$__DATA$__minfodata"
+
+#undef TARGET_D_MINFO_END_NAME
+#define TARGET_D_MINFO_END_NAME "*section$end$__DATA$__minfodata"
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
#undef TARGET_LIBC_HAS_FUNCTION
#define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
+
+/* ELF support needed only by D front-end. */
+
+#define TARGET_D_MINFO_SECTION "minfo"
+#define TARGET_D_MINFO_START_NAME "__start_minfo"
+#define TARGET_D_MINFO_END_NAME "__stop_minfo"
$(COMPILE) $(PREPROCESSOR_DEFINES) $<
$(POSTCOMPILE)
+darwin-d.o: $(srcdir)/config/darwin-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
darwin-f.o: $(srcdir)/config/darwin-f.c
$(COMPILE) $<
void, (void),
hook_void_void)
+/* ModuleInfo section name and brackets. */
+DEFHOOKPOD
+(d_minfo_section,
+ "Contains the name of the section in which module info references should be\n\
+placed. This section is expected to be bracketed by two symbols to indicate\n\
+the start and end address of the section, so that the runtime library can\n\
+collect all modules for each loaded shared library and executable. The\n\
+default value of @code{NULL} disables the use of sections altogether.",
+ const char *, NULL)
+
+DEFHOOKPOD
+(d_minfo_start_name,
+ "If @code{TARGET_D_MINFO_SECTION} is defined, then this must also be defined\n\
+as the name of the symbol indicating the start address of the module info\n\
+section",
+ const char *, NULL)
+
+/* The name of the ModuleInfo section. */
+DEFHOOKPOD
+(d_minfo_end_name,
+ "If @code{TARGET_D_MINFO_SECTION} is defined, then this must also be defined\n\
+as the name of the symbol indicating the end address of the module info\n\
+section",
+ const char *, NULL)
+
/* Close the 'struct gcc_targetdm' definition. */
HOOK_VECTOR_END (C90_EMPTY_HACK)
#include "stringpool.h"
#include "d-tree.h"
+#include "d-target.h"
/* D generates module information to inform the runtime library which modules
static void
register_moduleinfo (Module *decl, tree minfo)
{
+ /* No defined minfo section for target. */
+ if (targetdm.d_minfo_section == NULL)
+ return;
+
if (!targetm_common.have_named_sections)
sorry ("%<-fmoduleinfo%> is not supported on this target");
DECL_EXTERNAL (mref) = 0;
DECL_PRESERVE_P (mref) = 1;
- set_decl_section_name (mref, "minfo");
+ set_decl_section_name (mref, targetdm.d_minfo_section);
+ symtab_node::get (mref)->implicit_section = true;
d_pushdecl (mref);
rest_of_decl_compilation (mref, 1, 0);
if (!first_module)
return;
- start_minfo_node = build_dso_registry_var ("__start_minfo", ptr_type_node);
+ start_minfo_node = build_dso_registry_var (targetdm.d_minfo_start_name,
+ ptr_type_node);
rest_of_decl_compilation (start_minfo_node, 1, 0);
- stop_minfo_node = build_dso_registry_var ("__stop_minfo", ptr_type_node);
+ stop_minfo_node = build_dso_registry_var (targetdm.d_minfo_end_name,
+ ptr_type_node);
rest_of_decl_compilation (stop_minfo_node, 1, 0);
/* Declare dso_slot and dso_initialized. */
relating to the target operating system.
@end deftypefn
+@deftypevr {D Target Hook} {const char *} TARGET_D_MINFO_SECTION
+Contains the name of the section in which module info references should be
+placed. This section is expected to be bracketed by two symbols to indicate
+the start and end address of the section, so that the runtime library can
+collect all modules for each loaded shared library and executable. The
+default value of @code{NULL} disables the use of sections altogether.
+@end deftypevr
+
+@deftypevr {D Target Hook} {const char *} TARGET_D_MINFO_START_NAME
+If @code{TARGET_D_MINFO_SECTION} is defined, then this must also be defined
+as the name of the symbol indicating the start address of the module info
+section
+@end deftypevr
+
+@deftypevr {D Target Hook} {const char *} TARGET_D_MINFO_END_NAME
+If @code{TARGET_D_MINFO_SECTION} is defined, then this must also be defined
+as the name of the symbol indicating the end address of the module info
+section
+@end deftypevr
+
@node Named Address Spaces
@section Adding support for named address spaces
@cindex named address spaces
@hook TARGET_D_OS_VERSIONS
+@hook TARGET_D_MINFO_SECTION
+
+@hook TARGET_D_MINFO_START_NAME
+
+@hook TARGET_D_MINFO_END_NAME
+
@node Named Address Spaces
@section Adding support for named address spaces
@cindex named address spaces