aboutsummaryrefslogtreecommitdiff
path: root/libphobos/m4
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gcc.gnu.org>2018-10-28 19:51:47 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2018-10-28 19:51:47 +0000
commitb4c522fabd0df7be08882d2207df8b2765026110 (patch)
treeb5ffc312b0a441c1ba24323152aec463fdbe5e9f /libphobos/m4
parent01ce9e31a02c8039d88e90f983735104417bf034 (diff)
downloadgcc-b4c522fabd0df7be08882d2207df8b2765026110.zip
gcc-b4c522fabd0df7be08882d2207df8b2765026110.tar.gz
gcc-b4c522fabd0df7be08882d2207df8b2765026110.tar.bz2
Add D front-end, libphobos library, and D2 testsuite.
ChangeLog: * Makefile.def (target_modules): Add libphobos. (flags_to_pass): Add GDC, GDCFLAGS, GDC_FOR_TARGET and GDCFLAGS_FOR_TARGET. (dependencies): Make libphobos depend on libatomic, libbacktrace configure, and zlib configure. (language): Add language d. * Makefile.in: Rebuild. * Makefile.tpl (BUILD_EXPORTS): Add GDC and GDCFLAGS. (HOST_EXPORTS): Add GDC. (POSTSTAGE1_HOST_EXPORTS): Add GDC and GDC_FOR_BUILD. (BASE_TARGET_EXPORTS): Add GDC. (GDC_FOR_BUILD, GDC, GDCFLAGS): New variables. (GDC_FOR_TARGET, GDC_FLAGS_FOR_TARGET): New variables. (EXTRA_HOST_FLAGS): Add GDC. (STAGE1_FLAGS_TO_PASS): Add GDC. (EXTRA_TARGET_FLAGS): Add GDC and GDCFLAGS. * config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag environment variables. * configure: Rebuild. * configure.ac: Add target-libphobos to target_libraries. Set and substitute GDC_FOR_BUILD and GDC_FOR_TARGET. config/ChangeLog: * multi.m4: Set GDC. gcc/ChangeLog: * Makefile.in (tm_d_file_list, tm_d_include_list): New variables. (TM_D_H, D_TARGET_DEF, D_TARGET_H, D_TARGET_OBJS): New variables. (tm_d.h, cs-tm_d.h, default-d.o): New rules. (d/d-target-hooks-def.h, s-d-target-hooks-def-h): New rules. (s-tm-texi): Also check timestamp on d-target.def. (generated_files): Add TM_D_H and d-target-hooks-def.h. (build/genhooks.o): Also depend on D_TARGET_DEF. * config.gcc (tm_d_file, d_target_objs, target_has_targetdm): New variables. * config/aarch64/aarch64-d.c: New file. * config/aarch64/aarch64-linux.h (GNU_USER_TARGET_D_CRITSEC_SIZE): Define. * config/aarch64/aarch64-protos.h (aarch64_d_target_versions): New prototype. * config/aarch64/aarch64.h (TARGET_D_CPU_VERSIONS): Define. * config/aarch64/t-aarch64 (aarch64-d.o): New rule. * config/arm/arm-d.c: New file. * config/arm/arm-protos.h (arm_d_target_versions): New prototype. * config/arm/arm.h (TARGET_D_CPU_VERSIONS): Define. * config/arm/linux-eabi.h (EXTRA_TARGET_D_OS_VERSIONS): Define. * config/arm/t-arm (arm-d.o): New rule. * config/default-d.c: New file. * config/glibc-d.c: New file. * config/gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/i386/i386-d.c: New file. * config/i386/i386-protos.h (ix86_d_target_versions): New prototype. * config/i386/i386.h (TARGET_D_CPU_VERSIONS): Define. * config/i386/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Define. (GNU_USER_TARGET_D_CRITSEC_SIZE): Define. * config/i386/t-i386 (i386-d.o): New rule. * config/kfreebsd-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/kopensolaris-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/linux-android.h (ANDROID_TARGET_D_OS_VERSIONS): Define. * config/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/mips/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Define. * config/mips/mips-d.c: New file. * config/mips/mips-protos.h (mips_d_target_versions): New prototype. * config/mips/mips.h (TARGET_D_CPU_VERSIONS): Define. * config/mips/t-mips (mips-d.o): New rule. * config/powerpcspe/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/powerpcspe/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/powerpcspe/powerpcspe-d.c: New file. * config/powerpcspe/powerpcspe-protos.h (rs6000_d_target_versions): New prototype. * config/powerpcspe/powerpcspe.c (rs6000_output_function_epilogue): Support GNU D by using 0 as the language type. * config/powerpcspe/powerpcspe.h (TARGET_D_CPU_VERSIONS): Define. * config/powerpcspe/t-powerpcspe (powerpcspe-d.o): New rule. * config/riscv/riscv-d.c: New file. * config/riscv/riscv-protos.h (riscv_d_target_versions): New prototype. * config/riscv/riscv.h (TARGET_D_CPU_VERSIONS): Define. * config/riscv/t-riscv (riscv-d.o): New rule. * config/rs6000/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/rs6000/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define. * config/rs6000/rs6000-d.c: New file. * config/rs6000/rs6000-protos.h (rs6000_d_target_versions): New prototype. * config/rs6000/rs6000.c (rs6000_output_function_epilogue): Support GNU D by using 0 as the language type. * config/rs6000/rs6000.h (TARGET_D_CPU_VERSIONS): Define. * config/rs6000/t-rs6000 (rs6000-d.o): New rule. * config/s390/s390-d.c: New file. * config/s390/s390-protos.h (s390_d_target_versions): New prototype. * config/s390/s390.h (TARGET_D_CPU_VERSIONS): Define. * config/s390/t-s390 (s390-d.o): New rule. * config/sparc/sparc-d.c: New file. * config/sparc/sparc-protos.h (sparc_d_target_versions): New prototype. * config/sparc/sparc.h (TARGET_D_CPU_VERSIONS): Define. * config/sparc/t-sparc (sparc-d.o): New rule. * config/t-glibc (glibc-d.o): New rule. * configure: Regenerated. * configure.ac (tm_d_file): New variable. (tm_d_file_list, tm_d_include_list, d_target_objs): Add substitutes. * doc/contrib.texi (Contributors): Add self for the D frontend. * doc/frontends.texi (G++ and GCC): Mention D as a supported language. * doc/install.texi (Configuration): Mention libphobos as an option for --enable-shared. Mention d as an option for --enable-languages. (Testing): Mention check-d as a target. * doc/invoke.texi (Overall Options): Mention .d, .dd, and .di as file name suffixes. Mention d as a -x option. * doc/sourcebuild.texi (Top Level): Mention libphobos. * doc/standards.texi (Standards): Add section on D language. * doc/tm.texi: Regenerated. * doc/tm.texi.in: Add @node for D language and ABI, and @hook for TARGET_CPU_VERSIONS, TARGET_D_OS_VERSIONS, and TARGET_D_CRITSEC_SIZE. * dwarf2out.c (is_dlang): New function. (gen_compile_unit_die): Use DW_LANG_D for D. (declare_in_namespace): Return module die for D, instead of adding extra declarations into the namespace. (gen_namespace_die): Generate DW_TAG_module for D. (gen_decl_die): Handle CONST_DECLSs for D. (dwarf2out_decl): Likewise. (prune_unused_types_walk_local_classes): Handle DW_tag_interface_type. (prune_unused_types_walk): Handle DW_tag_interface_type same as other kinds of aggregates. * gcc.c (default_compilers): Add entries for .d, .dd and .di. * genhooks.c: Include d/d-target.def. gcc/po/ChangeLog: * EXCLUDES: Add sources from d/dmd. gcc/testsuite/ChangeLog: * gcc.misc-tests/help.exp: Add D to option descriptions check. * gdc.dg/asan/asan.exp: New file. * gdc.dg/asan/gdc272.d: New test. * gdc.dg/compilable.d: New test. * gdc.dg/dg.exp: New file. * gdc.dg/gdc254.d: New test. * gdc.dg/gdc260.d: New test. * gdc.dg/gdc270a.d: New test. * gdc.dg/gdc270b.d: New test. * gdc.dg/gdc282.d: New test. * gdc.dg/gdc283.d: New test. * gdc.dg/imports/gdc170.d: New test. * gdc.dg/imports/gdc231.d: New test. * gdc.dg/imports/gdc239.d: New test. * gdc.dg/imports/gdc241a.d: New test. * gdc.dg/imports/gdc241b.d: New test. * gdc.dg/imports/gdc251a.d: New test. * gdc.dg/imports/gdc251b.d: New test. * gdc.dg/imports/gdc253.d: New test. * gdc.dg/imports/gdc254a.d: New test. * gdc.dg/imports/gdc256.d: New test. * gdc.dg/imports/gdc27.d: New test. * gdc.dg/imports/gdcpkg256/package.d: New test. * gdc.dg/imports/runnable.d: New test. * gdc.dg/link.d: New test. * gdc.dg/lto/lto.exp: New file. * gdc.dg/lto/ltotests_0.d: New test. * gdc.dg/lto/ltotests_1.d: New test. * gdc.dg/runnable.d: New test. * gdc.dg/simd.d: New test. * gdc.test/gdc-test.exp: New file. * lib/gdc-dg.exp: New file. * lib/gdc.exp: New file. libphobos/ChangeLog: * Makefile.am: New file. * Makefile.in: New file. * acinclude.m4: New file. * aclocal.m4: New file. * config.h.in: New file. * configure: New file. * configure.ac: New file. * d_rules.am: New file. * libdruntime/Makefile.am: New file. * libdruntime/Makefile.in: New file. * libdruntime/__entrypoint.di: New file. * libdruntime/__main.di: New file. * libdruntime/gcc/attribute.d: New file. * libdruntime/gcc/backtrace.d: New file. * libdruntime/gcc/builtins.d: New file. * libdruntime/gcc/config.d.in: New file. * libdruntime/gcc/deh.d: New file. * libdruntime/gcc/libbacktrace.d.in: New file. * libdruntime/gcc/unwind/arm.d: New file. * libdruntime/gcc/unwind/arm_common.d: New file. * libdruntime/gcc/unwind/c6x.d: New file. * libdruntime/gcc/unwind/generic.d: New file. * libdruntime/gcc/unwind/package.d: New file. * libdruntime/gcc/unwind/pe.d: New file. * m4/autoconf.m4: New file. * m4/druntime.m4: New file. * m4/druntime/cpu.m4: New file. * m4/druntime/libraries.m4: New file. * m4/druntime/os.m4: New file. * m4/gcc_support.m4: New file. * m4/gdc.m4: New file. * m4/libtool.m4: New file. * src/Makefile.am: New file. * src/Makefile.in: New file. * src/libgphobos.spec.in: New file. * testsuite/Makefile.am: New file. * testsuite/Makefile.in: New file. * testsuite/config/default.exp: New file. * testsuite/lib/libphobos-dg.exp: New file. * testsuite/lib/libphobos.exp: New file. * testsuite/testsuite_flags.in: New file. From-SVN: r265573
Diffstat (limited to 'libphobos/m4')
-rw-r--r--libphobos/m4/autoconf.m4132
-rw-r--r--libphobos/m4/druntime.m4115
-rw-r--r--libphobos/m4/druntime/cpu.m495
-rw-r--r--libphobos/m4/druntime/libraries.m4163
-rw-r--r--libphobos/m4/druntime/os.m4184
-rw-r--r--libphobos/m4/gcc_support.m433
-rw-r--r--libphobos/m4/gdc.m418
-rw-r--r--libphobos/m4/libtool.m478
8 files changed, 818 insertions, 0 deletions
diff --git a/libphobos/m4/autoconf.m4 b/libphobos/m4/autoconf.m4
new file mode 100644
index 0000000..e1ed4a8
--- /dev/null
+++ b/libphobos/m4/autoconf.m4
@@ -0,0 +1,132 @@
+#
+# Minimal autoconf support for the D language.
+# Adapted from the Go language support files.
+#
+
+# ------------------- #
+# Language selection.
+# ------------------- #
+
+# AC_LANG(D)
+# -----------
+AC_LANG_DEFINE([D], [d], [GDC], [],
+[ac_ext=d
+ac_compile='$GDC -c $GDCFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$GDC -o conftest$ac_exeext $GDCFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
+ac_compiler_gnu=yes
+])
+
+# AC_LANG_D
+# ----------
+AU_DEFUN([AC_LANG_D], [AC_LANG(D)])
+
+# ------------------- #
+# Producing programs.
+# ------------------- #
+
+# AC_LANG_PROGRAM(D)([PROLOGUE], [BODY])
+# ---------------------------------------
+m4_define([AC_LANG_PROGRAM(D)],
+[module mod;
+$1
+
+extern(C) int main() {
+ $2
+}])
+
+# _AC_LANG_IO_PROGRAM(D)
+# -----------------------
+# Produce source that performs I/O.
+m4_define([_AC_LANG_IO_PROGRAM(D)],
+[AC_LANG_PROGRAM([import core.stdc.stdio;],
+[FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+])])
+
+# AC_LANG_CALL(D)(PROLOGUE, FUNCTION)
+# ------------------------------------
+# TODO: Avoid conflicting decl of main?
+# Used by AC_SEARCH_LIBS.
+m4_define([AC_LANG_CALL(D)],
+[AC_LANG_PROGRAM([$1 extern(C) int $2();], [$2(); return 0;])])
+
+# AC_LANG_FUNC_LINK_TRY(D)(FUNCTION)
+# -----------------------------------
+# Try to link a program which calls FUNCTION.
+# This only works for extern(C) functions.
+m4_define([AC_LANG_FUNC_LINK_TRY(D)],
+[AC_LANG_PROGRAM([extern(C) int $1();], [return $1();])])
+
+# AC_LANG_BOOL_COMPILE_TRY(D)(PROLOGUE, EXPRESSION)
+# --------------------------------------------------
+# Return a program which is valid if EXPRESSION is nonzero.
+# Probably not that useful for D, we can extract any information
+# we need using CTFE.
+m4_define([AC_LANG_BOOL_COMPILE_TRY(D)],
+[AC_LANG_PROGRAM([$1],
+[static assert($2); return 0;])])
+
+# AC_LANG_INT_SAVE(D)(PROLOGUE, EXPRESSION)
+# ------------------------------------------
+m4_define([AC_LANG_INT_SAVE(D)],
+[AC_LANG_PROGRAM([$1
+import core.stdc.stdio, core.stdc.stdlib;
+],
+[
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (($2) < 0)
+ {
+ fprintf (f, "%ld", $2);
+ }
+ else
+ {
+ fprintf (f, "%lu", $2);
+ }
+ /* Do not output a trailing newline, as this causes \r\n confusion
+ on some platforms. */
+ return ferror (f) || fclose (f) != 0;
+])])
+
+# ---------------------- #
+# Looking for compilers. #
+# ---------------------- #
+
+# AC_LANG_COMPILER(D)
+# --------------------
+AC_DEFUN([AC_LANG_COMPILER(D)],
+[AC_REQUIRE([AC_PROG_GDC])])
+
+# AC_PROG_GDC
+# ----------
+AN_MAKEVAR([GDC], [AC_PROG_GDC])
+AN_PROGRAM([gdc], [AC_PROG_GDC])
+AC_DEFUN([AC_PROG_GDC],
+[AC_LANG_PUSH(D)dnl
+AC_ARG_VAR([GDC], [D compiler command])dnl
+AC_ARG_VAR([GDCFLAGS], [D compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+m4_ifval([$1],
+ [AC_CHECK_TOOLS(GDC, [$1])],
+[AC_CHECK_TOOL(GDC, gdc)
+if test -z "$GDC"; then
+ if test -n "$ac_tool_prefix"; then
+ AC_CHECK_PROG(GDC, [${ac_tool_prefix}gdc], [$ac_tool_prefix}gdc])
+ fi
+fi
+if test -z "$GDC"; then
+ AC_CHECK_PROG(GDC, gdc, gdc, , , false)
+fi
+])
+
+# Provide some information about the compiler.
+_AS_ECHO_LOG([checking for _AC_LANG compiler version])
+set X $ac_compile
+ac_compiler=$[2]
+_AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
+AC_LANG_POP(D)dnl
+])# AC_PROG_D
+
diff --git a/libphobos/m4/druntime.m4 b/libphobos/m4/druntime.m4
new file mode 100644
index 0000000..ee9b8ed
--- /dev/null
+++ b/libphobos/m4/druntime.m4
@@ -0,0 +1,115 @@
+#
+# Contains some unsorted druntime utility macros.
+#
+
+
+# DRUNTIME_WERROR
+# ---------------
+# Check to see if -Werror is enabled.
+AC_DEFUN([DRUNTIME_WERROR],
+[
+ AC_ARG_ENABLE(werror, [AS_HELP_STRING([--enable-werror],
+ [turns on -Werror @<:@default=no@:>@])])
+ WERROR_FLAG=""
+ if test "x$enable_werror" = "xyes"; then
+ WERROR_FLAG="-Werror"
+ fi
+])
+
+
+# DRUNTIME_CONFIGURE
+# ------------------
+# Substitute absolute paths for srcdir and builddir.
+AC_DEFUN([DRUNTIME_CONFIGURE],
+[
+ # These need to be absolute paths, yet at the same time need to
+ # canonicalize only relative paths, because then amd will not unmount
+ # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
+ libphobos_builddir=`${PWDCMD-pwd}`
+ case $srcdir in
+ [\\/$]* | ?:[\\/]*) libphobos_srcdir=${srcdir} ;;
+ *) libphobos_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
+ esac
+ AC_SUBST(libphobos_builddir)
+ AC_SUBST(libphobos_srcdir)
+])
+
+# DRUNTIME_MULTILIB
+# -----------------
+# Prepare the multilib_arg variable
+AC_DEFUN([DRUNTIME_MULTILIB],
+[
+ if test ${multilib} = yes; then
+ multilib_arg="--enable-multilib"
+ else
+ multilib_arg=
+ fi
+])
+
+
+# DRUNTIME_INSTALL_DIRECTORIES
+# ----------------------------
+# Setup various install directories for headers.
+# Add the cross-host option and substitute the toolexecdir
+# toolexeclibdir and gdc_include_dir variables.
+AC_DEFUN([DRUNTIME_INSTALL_DIRECTORIES],
+[
+ AC_REQUIRE([AC_PROG_GDC])
+
+ AC_MSG_CHECKING([D GCC version])
+ gcc_version=`eval $get_gcc_base_ver $srcdir/../gcc/BASE-VER`
+ AC_MSG_RESULT($gcc_version)
+ AC_SUBST(gcc_version)
+
+ AC_ARG_WITH([cross-host],
+ AC_HELP_STRING([--with-cross-host=HOST],
+ [configuring with a cross compiler]))
+
+ toolexecdir=no
+ toolexeclibdir=no
+
+ version_specific_libs=no
+
+ # Version-specific runtime libs processing.
+ if test $version_specific_libs = yes; then
+ toolexecdir='${libdir}/gcc/${host_alias}'
+ toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
+ else
+ # Calculate toolexecdir, toolexeclibdir
+ # Install a library built with a cross compiler in tooldir, not libdir.
+ if test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
+ toolexecdir='${exec_prefix}/${host_alias}'
+ toolexeclibdir='${toolexecdir}/lib'
+ else
+ toolexecdir='${libdir}/gcc/${host_alias}'
+ toolexeclibdir='${libdir}'
+ fi
+ multi_os_directory=`$GDC -print-multi-os-directory`
+ case $multi_os_directory in
+ .) ;; # Avoid trailing /.
+ *) toolexeclibdir=${toolexeclibdir}/${multi_os_directory} ;;
+ esac
+ fi
+ AC_SUBST(toolexecdir)
+ AC_SUBST(toolexeclibdir)
+
+ # Default case for install directory for D sources files.
+ gdc_include_dir='$(libdir)/gcc/${target_alias}/${gcc_version}/include/d'
+ AC_SUBST(gdc_include_dir)
+])
+
+
+# DRUNTIME_GC
+# -----------
+# Add the --enable-druntime-gc option and create the
+# DRUNTIME_GC_ENABLE conditional
+AC_DEFUN([DRUNTIME_GC],
+[
+ dnl switch between gc and gcstub
+ AC_ARG_ENABLE(druntime-gc,
+ AC_HELP_STRING([--enable-druntime-gc],
+ [enable D runtime garbage collector (default: yes)]),
+ [enable_druntime_gc=no],[enable_druntime_gc=yes])
+
+ AM_CONDITIONAL([DRUNTIME_GC_ENABLE], [test "$enable_druntime_gc" = "yes"])
+])
diff --git a/libphobos/m4/druntime/cpu.m4 b/libphobos/m4/druntime/cpu.m4
new file mode 100644
index 0000000..7f7b138
--- /dev/null
+++ b/libphobos/m4/druntime/cpu.m4
@@ -0,0 +1,95 @@
+#
+# Contains macros to detect CPU features.
+#
+
+
+# DRUNTIME_ENABLE_ATOMIC_BUILTINS
+# -------------------------
+# Check support for atomic builtins up to 64 bit.
+AC_DEFUN([DRUNTIME_ENABLE_ATOMIC_BUILTINS],
+[
+ # This checks to see if the host supports the compiler-generated builtins
+ # for atomic operations for various integral sizes. Note, this is intended
+ # to be an all-or-nothing switch, so all the atomic operations that are
+ # used should be checked.
+ AC_MSG_CHECKING([for atomic builtins for byte])
+ AC_CACHE_VAL(druntime_cv_atomic_byte, [
+ AC_TRY_LINK(
+ [import gcc.builtins;], [
+ shared(byte) c1;
+ byte c2, c3;
+ __atomic_compare_exchange_1(&c1, &c2, c3, false, 5, 5);
+ __atomic_load_1(&c1, 5);
+ __atomic_store_1(&c1, c2, 5);
+ return 0;
+ ],
+ [druntime_cv_atomic_byte=yes],
+ [druntime_cv_atomic_byte=no])
+ ])
+ AC_MSG_RESULT($druntime_cv_atomic_byte)
+
+ AC_MSG_CHECKING([for atomic builtins for short])
+ AC_CACHE_VAL(druntime_cv_atomic_short, [
+ AC_TRY_LINK(
+ [import gcc.builtins;], [
+ shared(short) c1;
+ short c2, c3;
+ __atomic_compare_exchange_2(&c1, &c2, c3, false, 5, 5);
+ __atomic_load_2(&c1, 5);
+ __atomic_store_2(&c1, c2, 5);
+ return 0;
+ ],
+ [druntime_cv_atomic_short=yes],
+ [druntime_cv_atomic_short=no])
+ ])
+ AC_MSG_RESULT($druntime_cv_atomic_short)
+
+ AC_MSG_CHECKING([for atomic builtins for int])
+ AC_CACHE_VAL(druntime_cv_atomic_int, [
+ AC_TRY_LINK(
+ [import gcc.builtins;], [
+ shared(int) c1;
+ int c2, c3;
+ __atomic_compare_exchange_4(&c1, &c2, c3, false, 5, 5);
+ __atomic_load_4(&c1, 5);
+ __atomic_store_4(&c1, c2, 5);
+ return 0;
+ ],
+ [druntime_cv_atomic_int=yes],
+ [druntime_cv_atomic_int=no])
+ ])
+ AC_MSG_RESULT($druntime_cv_atomic_int)
+
+ AC_MSG_CHECKING([for atomic builtins for long])
+ AC_CACHE_VAL(druntime_cv_atomic_long, [
+ AC_TRY_LINK(
+ [import gcc.builtins;], [
+ shared(long) c1;
+ long c2, c3;
+ __atomic_compare_exchange_8(&c1, &c2, c3, false, 5, 5);
+ __atomic_load_8(&c1, 5);
+ __atomic_store_8(&c1, c2, 5);
+ return 0;
+ ],
+ [druntime_cv_atomic_long=yes],
+ [druntime_cv_atomic_long=no])
+ ])
+ AC_MSG_RESULT($druntime_cv_atomic_long)
+
+ # Have atomic builtin support if all but the long test above passes.
+ DCFG_HAVE_ATOMIC_BUILTINS=false
+ if test "$druntime_cv_atomic_byte" = yes \
+ && test "$druntime_cv_atomic_short" = yes \
+ && test "$druntime_cv_atomic_int" = yes; then \
+ DCFG_HAVE_ATOMIC_BUILTINS=true
+ fi
+
+ # Have 64-bit atomic support if the long test above passes.
+ DCFG_HAVE_64BIT_ATOMICS=false
+ if test "$druntime_cv_atomic_long" = yes; then
+ DCFG_HAVE_64BIT_ATOMICS=true
+ fi
+
+ AC_SUBST(DCFG_HAVE_ATOMIC_BUILTINS)
+ AC_SUBST(DCFG_HAVE_64BIT_ATOMICS)
+])
diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4
new file mode 100644
index 0000000..17f9346
--- /dev/null
+++ b/libphobos/m4/druntime/libraries.m4
@@ -0,0 +1,163 @@
+#
+# Contains macros to handle library dependencies.
+#
+
+
+# DRUNTIME_LIBRARIES_THREAD
+# -------------------------
+# Allow specifying the thread library to link with or autodetect
+# Add thread library to LIBS if necessary.
+AC_DEFUN([DRUNTIME_LIBRARIES_THREAD],
+[
+ enable_thread_lib=yes
+ AC_ARG_ENABLE(thread-lib,
+ AC_HELP_STRING([--enable-thread-lib=<arg>],
+ [specify linker option for the system thread library (default: autodetect)]))
+
+ AS_IF([test "x$enable_thread_lib" = "xyes"], [
+ AC_SEARCH_LIBS([pthread_create], [pthread])
+ ], [
+ AS_IF([test "x$enable_thread_lib" = "xno"], [
+ AC_MSG_CHECKING([for thread library])
+ AC_MSG_RESULT([disabled])
+ ], [
+ AC_CHECK_LIB([$enable_thread_lib], [pthread_create], [], [
+ AC_MSG_ERROR([Thread library not found])
+ ])
+ ])
+ ])
+])
+
+
+# DRUNTIME_LIBRARIES_DLOPEN
+# -----------------------
+# Autodetect and add dl library to LIBS if necessary.
+AC_DEFUN([DRUNTIME_LIBRARIES_DLOPEN],
+[
+ # Libtool has already checked this, so re-use the inferred dlopen lib.
+ AS_IF([test "x$enable_dlopen" = "xyes" && test -n "$lt_cv_dlopen_libs"], [
+ LIBS="$LIBS $lt_cv_dlopen_libs"
+ ], [
+ ])
+])
+
+
+# DRUNTIME_LIBRARIES_ZLIB
+# -----------------------
+# Allow specifying whether to use the system zlib or
+# compiling the zlib included in GCC. Define
+# DRUNTIME_ZLIB_SYSTEM conditional and add zlib to
+# LIBS if necessary.
+AC_DEFUN([DRUNTIME_LIBRARIES_ZLIB],
+[
+ AC_ARG_WITH(target-system-zlib,
+ AS_HELP_STRING([--with-target-system-zlib],
+ [use installed libz (default: no)]))
+
+ system_zlib=false
+ AS_IF([test "x$with_target_system_zlib" = "xyes"], [
+ AC_CHECK_LIB([z], [deflate], [
+ system_zlib=yes
+ ], [
+ AC_MSG_ERROR([System zlib not found])
+ ])
+ ], [
+ AC_MSG_CHECKING([for zlib])
+ AC_MSG_RESULT([just compiled])
+ ])
+
+ AM_CONDITIONAL([DRUNTIME_ZLIB_SYSTEM], [test "$with_target_system_zlib" = yes])
+])
+
+# DRUNTIME_LIBRARIES_ATOMIC
+# -------------------------
+# Allow specifying whether to use libatomic for atomic support.
+AC_DEFUN([DRUNTIME_LIBRARIES_ATOMIC],
+[
+ AC_ARG_WITH(libatomic,
+ AS_HELP_STRING([--without-libatomic],
+ [Do not use libatomic in core.atomic (default: auto)]))
+
+ DCFG_HAVE_LIBATOMIC=false
+ LIBATOMIC=
+ AS_IF([test "x$with_libatomic" != "xno"], [
+ DCFG_HAVE_LIBATOMIC=true
+ LIBATOMIC=../../libatomic/libatomic_convenience.la
+ ], [
+ AC_MSG_CHECKING([for libatomic])
+ AC_MSG_RESULT([disabled])
+ ])
+
+ AC_SUBST(DCFG_HAVE_LIBATOMIC)
+ AC_SUBST(LIBATOMIC)
+])
+
+# DRUNTIME_LIBRARIES_BACKTRACE
+# ---------------------------
+# Allow specifying whether to use libbacktrace for backtrace support.
+# Adds subsitute for BACKTRACE_SUPPORTED, BACKTRACE_USES_MALLOC,
+# and BACKTRACE_SUPPORTS_THREADS.
+AC_DEFUN([DRUNTIME_LIBRARIES_BACKTRACE],
+[
+ AC_LANG_PUSH([C])
+ BACKTRACE_SUPPORTED=false
+ BACKTRACE_USES_MALLOC=false
+ BACKTRACE_SUPPORTS_THREADS=false
+ LIBBACKTRACE=""
+
+ AC_ARG_WITH(libbacktrace,
+ AS_HELP_STRING([--without-libbacktrace],
+ [Do not use libbacktrace in core.runtime (default: auto)]))
+
+ AS_IF([test "x$with_libbacktrace" != "xno"], [
+ LIBBACKTRACE=../../libbacktrace/libbacktrace.la
+
+ gdc_save_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS+=" -I../libbacktrace "
+
+ AC_CHECK_HEADER(backtrace-supported.h, have_libbacktrace_h=true,
+ have_libbacktrace_h=false)
+
+ if $have_libbacktrace_h; then
+ AC_MSG_CHECKING([libbacktrace: BACKTRACE_SUPPORTED])
+ AC_EGREP_CPP(FOUND_LIBBACKTRACE_RESULT_GDC,
+ [
+ #include <backtrace-supported.h>
+ #if BACKTRACE_SUPPORTED
+ FOUND_LIBBACKTRACE_RESULT_GDC
+ #endif
+ ], BACKTRACE_SUPPORTED=true, BACKTRACE_SUPPORTED=false)
+ AC_MSG_RESULT($BACKTRACE_SUPPORTED)
+
+ AC_MSG_CHECKING([libbacktrace: BACKTRACE_USES_MALLOC])
+ AC_EGREP_CPP(FOUND_LIBBACKTRACE_RESULT_GDC,
+ [
+ #include <backtrace-supported.h>
+ #if BACKTRACE_USES_MALLOC
+ FOUND_LIBBACKTRACE_RESULT_GDC
+ #endif
+ ], BACKTRACE_USES_MALLOC=true, BACKTRACE_USES_MALLOC=false)
+ AC_MSG_RESULT($BACKTRACE_USES_MALLOC)
+
+ AC_MSG_CHECKING([libbacktrace: BACKTRACE_SUPPORTS_THREADS])
+ AC_EGREP_CPP(FOUND_LIBBACKTRACE_RESULT_GDC,
+ [
+ #include <backtrace-supported.h>
+ #if BACKTRACE_SUPPORTS_THREADS
+ FOUND_LIBBACKTRACE_RESULT_GDC
+ #endif
+ ], BACKTRACE_SUPPORTS_THREADS=true, BACKTRACE_SUPPORTS_THREADS=false)
+ AC_MSG_RESULT($BACKTRACE_SUPPORTS_THREADS)
+ fi
+ CPPFLAGS=$gdc_save_CPPFLAGS
+ ], [
+ AC_MSG_CHECKING([for libbacktrace])
+ AC_MSG_RESULT([disabled])
+ ])
+
+ AC_SUBST(LIBBACKTRACE)
+ AC_SUBST(BACKTRACE_SUPPORTED)
+ AC_SUBST(BACKTRACE_USES_MALLOC)
+ AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
+ AC_LANG_POP([C])
+])
diff --git a/libphobos/m4/druntime/os.m4 b/libphobos/m4/druntime/os.m4
new file mode 100644
index 0000000..6ec7b41
--- /dev/null
+++ b/libphobos/m4/druntime/os.m4
@@ -0,0 +1,184 @@
+#
+# Contains macros to detect OS features.
+#
+
+
+# DRUNTIME_OS_THREAD_MODEL
+# ------------------------
+# Detect thread model and substitute DCFG_THREAD_MODEL
+AC_DEFUN([DRUNTIME_OS_THREAD_MODEL],
+[
+ AC_REQUIRE([AC_PROG_GDC])
+ AC_MSG_CHECKING([for thread model used by GDC])
+ d_thread_model=`$GDC -v 2>&1 | sed -n 's/^Thread model: //p'`
+ AC_MSG_RESULT([$d_thread_model])
+
+ # Map from thread model to thread interface.
+ DRUNTIME_CONFIGURE_THREADS([$d_thread_model])
+])
+
+
+# DRUNTIME_CONFIGURE_THREADS(thread_model)
+# ----------------------------------------
+# Map target os to D version identifier
+AC_DEFUN([DRUNTIME_CONFIGURE_THREADS],
+[
+case $1 in
+ aix) DCFG_THREAD_MODEL="Posix" ;;
+ lynx) DCFG_THREAD_MODEL="Posix" ;;
+ posix) DCFG_THREAD_MODEL="Posix" ;;
+ single) DCFG_THREAD_MODEL="Single" ;;
+ win32) DCFG_THREAD_MODEL="Win32" ;;
+ # TODO: These targets need porting.
+ dce|mipssde|rtems|tpf|vxworks)
+ DCFG_THREAD_MODEL="Single" ;;
+ *) as_fn_error "Thread implementation '$1' not recognised" "$LINENO" 5 ;;
+esac
+AC_SUBST(DCFG_THREAD_MODEL)
+])
+
+
+# DRUNTIME_OS_DETECT
+# ------------------
+# Set the druntime_cv_target_os variable
+AC_DEFUN([DRUNTIME_OS_DETECT],
+[
+ AC_CACHE_CHECK([[for target OS]],
+ [[druntime_cv_target_os]],
+ [[druntime_cv_target_os=`echo $target_os | sed 's/^\([A-Za-z_]+\)/\1/'`]])
+ AS_IF([[test -z "$druntime_cv_target_os"]],
+ [AC_MSG_ERROR([[can't detect target OS]])],
+ [])
+])
+
+
+# DRUNTIME_OS_UNIX
+# ----------------
+# Add --enable-unix option or autodetects if system is unix
+# and create the DRUNTIME_OS_UNIX conditional.
+AC_DEFUN([DRUNTIME_OS_UNIX],
+[
+ AC_REQUIRE([DRUNTIME_OS_DETECT])
+ AC_ARG_ENABLE(unix,
+ AC_HELP_STRING([--enable-unix],
+ [enables Unix runtime (default: yes, for Unix targets)]),
+ :,[enable_unix=auto])
+
+ case "$druntime_cv_target_os" in
+ aix*|*bsd*|cygwin*|darwin*|gnu*|linux*|skyos*|*solaris*|sysv*) d_have_unix=1 ;;
+ esac
+ if test -n "$d_have_unix" && test "$enable_unix" = auto ; then
+ enable_unix=yes
+ fi
+ AM_CONDITIONAL([DRUNTIME_OS_UNIX], [test "$enable_unix" = "yes"])
+])
+
+
+# DRUNTIME_OS_SOURCES
+# -------------------
+# Detect target OS and add DRUNTIME_OS_AIX DRUNTIME_OS_DARWIN
+# DRUNTIME_OS_FREEBSD DRUNTIME_OS_LINUX DRUNTIME_OS_MINGW
+# DRUNTIME_OS_SOLARIS DRUNTIME_OS_OPENBSD conditionals.
+AC_DEFUN([DRUNTIME_OS_SOURCES],
+[
+ AC_REQUIRE([DRUNTIME_OS_DETECT])
+
+ druntime_target_os_parsed=""
+ case "$druntime_cv_target_os" in
+ aix*) druntime_target_os_parsed="aix"
+ ;;
+ *android*)
+ druntime_target_os_parsed="android"
+ ;;
+ darwin*) druntime_target_os_parsed="darwin"
+ ;;
+ dragonfly*)
+ druntime_target_os_parsed="dragonflybsd"
+ ;;
+ freebsd*|k*bsd*-gnu)
+ druntime_target_os_parsed="freebsd"
+ ;;
+ openbsd*)
+ druntime_target_os_parsed="openbsd"
+ ;;
+ netbsd*)
+ druntime_target_os_parsed="netbsd"
+ ;;
+ linux*) druntime_target_os_parsed="linux"
+ ;;
+ mingw*) druntime_target_os_parsed="mingw"
+ ;;
+ *solaris*) druntime_target_os_parsed="solaris"
+ esac
+ AM_CONDITIONAL([DRUNTIME_OS_AIX],
+ [test "$druntime_target_os_parsed" = "aix"])
+ AM_CONDITIONAL([DRUNTIME_OS_ANDROID],
+ [test "$druntime_target_os_parsed" = "android"])
+ AM_CONDITIONAL([DRUNTIME_OS_DARWIN],
+ [test "$druntime_target_os_parsed" = "darwin"])
+ AM_CONDITIONAL([DRUNTIME_OS_DRAGONFLYBSD],
+ [test "$druntime_target_os_parsed" = "dragonflybsd"])
+ AM_CONDITIONAL([DRUNTIME_OS_FREEBSD],
+ [test "$druntime_target_os_parsed" = "freebsd"])
+ AM_CONDITIONAL([DRUNTIME_OS_NETBSD],
+ [test "$druntime_target_os_parsed" = "netbsd"])
+ AM_CONDITIONAL([DRUNTIME_OS_OPENBSD],
+ [test "$druntime_target_os_parsed" = "openbsd"])
+ AM_CONDITIONAL([DRUNTIME_OS_LINUX],
+ [test "$druntime_target_os_parsed" = "linux"])
+ AM_CONDITIONAL([DRUNTIME_OS_MINGW],
+ [test "$druntime_target_os_parsed" = "mingw"])
+ AM_CONDITIONAL([DRUNTIME_OS_SOLARIS],
+ [test "$druntime_target_os_parsed" = "solaris"])
+])
+
+
+# DRUNTIME_OS_ARM_EABI_UNWINDER
+# ------------------------
+# Check if using ARM unwinder and substitute DCFG_ARM_EABI_UNWINDER
+# and set DRUNTIME_OS_ARM_EABI_UNWINDER conditional.
+AC_DEFUN([DRUNTIME_OS_ARM_EABI_UNWINDER],
+[
+ AC_LANG_PUSH([C])
+ AC_MSG_CHECKING([for ARM unwinder])
+ AC_TRY_COMPILE([#include <unwind.h>],[
+ #if __ARM_EABI_UNWINDER__
+ #error Yes, it is.
+ #endif
+ ],
+ [AC_MSG_RESULT([no])
+ DCFG_ARM_EABI_UNWINDER=false],
+ [AC_MSG_RESULT([yes])
+ DCFG_ARM_EABI_UNWINDER=true])
+ AC_SUBST(DCFG_ARM_EABI_UNWINDER)
+ AM_CONDITIONAL([DRUNTIME_OS_ARM_EABI_UNWINDER], [test "$DCFG_ARM_EABI_UNWINDER" = "true"])
+ AC_LANG_POP([C])
+])
+
+
+# DRUNTIME_OS_MINFO_BRACKETING
+# ----------------------------
+# Check if the linker provides __start_minfo and __stop_minfo symbols and
+# substitute DCFG_MINFO_BRACKETING.
+AC_DEFUN([DRUNTIME_OS_MINFO_BRACKETING],
+[
+ AC_LANG_PUSH([C])
+ AC_MSG_CHECKING([for minfo section bracketing])
+ AC_LINK_IFELSE([
+ void* module_info_ptr __attribute__((section ("minfo")));
+ extern void* __start_minfo __attribute__((visibility ("hidden")));
+ extern void* __stop_minfo __attribute__((visibility ("hidden")));
+
+ int main()
+ {
+ // Never run, just to prevent compiler from optimizing access
+ return &__start_minfo == &__stop_minfo;
+ }
+ ],
+ [AC_MSG_RESULT([yes])
+ DCFG_MINFO_BRACKETING=true],
+ [AC_MSG_RESULT([no])
+ DCFG_MINFO_BRACKETING=false])
+ AC_SUBST(DCFG_MINFO_BRACKETING)
+ AC_LANG_POP([C])
+])
diff --git a/libphobos/m4/gcc_support.m4 b/libphobos/m4/gcc_support.m4
new file mode 100644
index 0000000..0903ed4
--- /dev/null
+++ b/libphobos/m4/gcc_support.m4
@@ -0,0 +1,33 @@
+#
+# Contains macros to allow building libphobos as part of GCC.
+# This includes macros to locate directories and do configure checks
+# without an installed libdruntime.
+#
+
+
+# PHOBOS_ABS_SRCDIR
+# -----------------
+# Find absolute top level source directory and set phobos_cv_abs_srcdir
+AC_DEFUN([PHOBOS_ABS_SRCDIR], [
+ dnl Not sure if 100% portable, but we need the absolute dir as the _LT_COMPILER_C_O
+ dnl test changes the directory
+ AC_CACHE_CHECK([[for absolute libphobos source path]],
+ [[phobos_cv_abs_srcdir]],
+ [[phobos_cv_abs_srcdir=`cd $srcdir && pwd`]])
+ AS_IF([[test -d "$phobos_cv_abs_srcdir"]],
+ [],
+ [AC_MSG_ERROR([[can't find absolute libphobos source path]])])
+])
+
+
+# WITH_LOCAL_DRUNTIME(CALL, EXTRAFLAGS)
+# -------------------------------------
+# Execute CALL with GDCFLAGS adjusted to use the local druntime includes.
+# Flags contains extra arguments to append to GDCFLAGS (e.g. -nophoboslib).
+AC_DEFUN([WITH_LOCAL_DRUNTIME], [
+ AC_REQUIRE([PHOBOS_ABS_SRCDIR])
+ gdc_save_DFLAGS=$GDCFLAGS
+ GDCFLAGS="-fno-moduleinfo -nostdinc -I $phobos_cv_abs_srcdir/libdruntime $2 $GDCFLAGS"
+ $1
+ GDCFLAGS=$gdc_save_DFLAGS
+])
diff --git a/libphobos/m4/gdc.m4 b/libphobos/m4/gdc.m4
new file mode 100644
index 0000000..1ba8834
--- /dev/null
+++ b/libphobos/m4/gdc.m4
@@ -0,0 +1,18 @@
+#
+# GDC feature checking and sanity check macros
+#
+
+
+# GDC_CHECK_COMPILE
+# -----------------
+# Check if compiler can compile D code
+AC_DEFUN([GDC_CHECK_COMPILE],
+[
+ AC_LANG_PUSH(D)
+ AC_MSG_CHECKING([[If $GDC can compile D sources]])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return 0;]])],
+ [AC_MSG_RESULT([[yes]])],
+ [AC_MSG_RESULT([[no]])
+ AC_MSG_ERROR([[can't compile D sources!]])])
+ AC_LANG_POP(D)
+])
diff --git a/libphobos/m4/libtool.m4 b/libphobos/m4/libtool.m4
new file mode 100644
index 0000000..44ca572
--- /dev/null
+++ b/libphobos/m4/libtool.m4
@@ -0,0 +1,78 @@
+#
+# Minimal libtool support for the D language.
+# Adapted from the Go language support files.
+#
+
+# _LT_LANG_D_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU D compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_D_CONFIG],
+[AC_REQUIRE([AC_PROG_GDC])dnl
+AC_LANG_SAVE
+
+# Source file extension for D test sources.
+ac_ext=d
+
+# Object file extension for compiled D test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="module mod; extern(C) int main() { return 0; }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='module mod; extern(C) int main() { return 0; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_DFLAGS=$GDCFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GDC-"gdc"}
+# Need to specify location for object.d
+GDCFLAGS="-nophoboslib $GDCFLAGS"
+CFLAGS=$GDCFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# GDC did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+GDCFLAGS=$lt_save_DFLAGS
+])# _LT_LANG_D_CONFIG