extern void darwin_rename_builtins (void);
extern bool darwin_libc_has_function (enum function_class fn_class, tree);
+/* For this port, there are several possible sources for external toolchain
+ components (e.g. as, ld, dsymutil) and we have to alter the allowable
+ output in response to which version and source is in use. */
+enum darwin_external_toolchain {
+ DET_UNKNOWN=0,
+ CCTOOLS,
+ DWARFUTILS,
+ LLVM,
+ CLANG
+};
+
#endif /* CONFIG_DARWIN_PROTOS_H */
/* Emit a section-start symbol for mod init and term sections. */
static bool ld_init_term_start_labels = false;
+/* The source and version of dsymutil in use. */
+#ifndef DSYMUTIL_VERSION
+# warning Darwin toolchain without a defined dsymutil.
+# define DSYMUTIL_VERSION DET_UNKNOWN,0,0,0
+#endif
+
+struct {
+ darwin_external_toolchain kind; /* cctools, llvm, clang etc. */
+ int major; /* version number. */
+ int minor;
+ int tiny;
+} dsymutil_version = {DSYMUTIL_VERSION};
+
/* Section names. */
section * darwin_sections[NUM_DARWIN_SECTIONS];
global_options.x_flag_objc_abi);
}
- /* Don't emit DWARF3/4 unless specifically selected. This is a
- workaround for tool bugs. */
+ /* Limit DWARF to the chosen version, the linker and debug linker might not
+ be able to consume newer structures. */
if (!OPTION_SET_P (dwarf_strict))
dwarf_strict = 1;
+
if (!OPTION_SET_P (dwarf_version))
- dwarf_version = 2;
+ {
+ /* External toolchains based on LLVM or clang 7+ have support for
+ dwarf-4. */
+ if ((dsymutil_version.kind == LLVM && dsymutil_version.major >= 7)
+ || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 7))
+ dwarf_version = 4;
+ else if (dsymutil_version.kind == DWARFUTILS
+ && dsymutil_version.major >= 121)
+ dwarf_version = 3; /* From XC 6.4. */
+ else
+ dwarf_version = 2; /* Older cannot safely exceed dwarf-2. */
+ }
- if (OPTION_SET_P (dwarf_split_debug_info))
+ if (OPTION_SET_P (dwarf_split_debug_info) && dwarf_split_debug_info)
{
inform (input_location,
"%<-gsplit-dwarf%> is not supported on this platform, ignored");