mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 18:33:58 +00:00
--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)
Also deprecate the internal compiler option --cflags-for-ansi.
compiler/options.m:
Document that --no-ansi-c is now deprecated.
Document that the internal option --cflags-for-ansi is now
deprecated.
compiler/compile_target_code.m:
Do not pass the ANSI options to the C compiler.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Deprecate the --no-ansi option; delete code that no longer does
anything useful.
configure.ac:
Delete the configuration variable CFLAGS_FOR_ANSI; it is only ever
set to be empty. (The comment talks about --no-ansi doing other things
in the mgnuc script. It used to also cause some preprocessor macros
to be defined for compatibility with the system headers on some
platforms -- that has not been the case since 2013.)
doc/user_guide.texi:
Document that --no-ansi-c is deprecated.
bytecode/Mmakefile:
compiler/Mercury.options:
library/Mercury.options:
extras/odbc/odbc.m:
runtime/Mmakefile:
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
tests/hard_coded/Mercury.options:
tests/valid/Mercury.options:
trace/Mmakefile:
util/Mmakefile:
Conform to the above change.
NEWS.md:
Announce the above.
736 lines
22 KiB
Bash
736 lines
22 KiB
Bash
#! /bin/sh
|
|
#---------------------------------------------------------------------------#
|
|
# vim: ts=4 sw=4 expandtab ft=sh
|
|
#---------------------------------------------------------------------------#
|
|
# @configure_input@
|
|
#---------------------------------------------------------------------------#
|
|
# Copyright (C) 1995-2007, 2010-2012 The University of Melbourne.
|
|
# Copyright (C) 2013-2020, 2022-2023 The Mercury team.
|
|
# This file may only be copied under the terms of the GNU General
|
|
# Public License - see the file COPYING in the Mercury distribution.
|
|
#---------------------------------------------------------------------------#
|
|
#
|
|
# IMPORTANT: the manpage is produced automatically from this help
|
|
# message, so if you change the help message, don't forget to check
|
|
# that the manpage still looks OK.
|
|
|
|
# *************************************************************************
|
|
# *** IMPORTANT NOTE: any changes to this file may also require similar ***
|
|
# *** changes to compiler/compile_target_code.m ***
|
|
# *************************************************************************
|
|
|
|
FULLARCH=@FULLARCH@
|
|
|
|
DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@}
|
|
CC=${MERCURY_C_COMPILER="@CC@"}
|
|
C_COMPILER_TYPE=${MERCURY_C_COMPILER_TYPE="@C_COMPILER_TYPE@"}
|
|
CFLAGS_FOR_REGS="@CFLAGS_FOR_REGS@"
|
|
CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@"
|
|
CFLAGS_FOR_THREADS="@CFLAGS_FOR_THREADS@"
|
|
CFLAGS_FOR_LTO="@CFLAGS_FOR_LTO@"
|
|
CFLAGS_FOR_NO_STRICT_ALIASING="@CFLAGS_FOR_NO_STRICT_ALIASING@"
|
|
CFLAGS_FOR_ANSI="@CFLAGS_FOR_ANSI@"
|
|
CFLAGS_FOR_SANITIZERS="@CFLAGS_FOR_SANITIZERS@"
|
|
BYTES_PER_WORD="@BYTES_PER_WORD@"
|
|
MKTEMP=@MKTEMP@
|
|
TMPDIR=${TMPDIR=/tmp}
|
|
|
|
case "${C_COMPILER_TYPE}" in
|
|
gcc*)
|
|
CHECK_OPTS="
|
|
-Wall -Wwrite-strings
|
|
-Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wno-unused"
|
|
|
|
# Note: we do not enable the following gcc warnings:
|
|
# -Wredundant-decls causes too many complaints in system header files
|
|
# -Wpointer-arith causes too many complaints in system header files
|
|
# (fixed in gcc 3.0, though, so at some point
|
|
# we should re-enable this)
|
|
# -Wtraditional we don't care about compatibility with pre-ANSI C
|
|
# -Wconversion really only intended to help people using \`unprotoize'
|
|
# -Waggregate-return not useful, IMHO
|
|
|
|
# -Wcast-qual causes LOTS of redundant warnings
|
|
# -Wcast-align causes redundant warnings in memory.c
|
|
# -pedantic causes unsuppressable warnings about LVALUE_CAST()
|
|
# -Wnested-externs causes unsuppressable warnings about callentry()
|
|
# -Wid-clash-31 causes warnings about entry_mercury__xxx ...
|
|
# we don't care about compatibility with C compilers
|
|
# that have short fixed limits on identifier length
|
|
# -Wenum-clash is for C++ only
|
|
# -Wunused causes various spurious warnings
|
|
|
|
# Enabling -fomit-frame-pointer causes setjmp/longjmp to misbehave
|
|
# with MinGW on Windows XP.
|
|
case "${FULLARCH}" in
|
|
*mingw*)
|
|
OPT_OPTS="-O2 ${CFLAGS_FOR_NO_STRICT_ALIASING}"
|
|
;;
|
|
*)
|
|
OPT_OPTS="-O2 ${CFLAGS_FOR_NO_STRICT_ALIASING} -fomit-frame-pointer"
|
|
;;
|
|
esac
|
|
DEBUG_OPTS="-g"
|
|
DISABLE_OPTS_OPT="-O0"
|
|
COMPILER_HALT_AT_WARN_OPT="-Werror"
|
|
COMPILER=gcc
|
|
;;
|
|
clang*)
|
|
CHECK_OPTS="-w"
|
|
OPT_OPTS="@OPT_FLAGS_FOR_CLANG@ ${CFLAGS_FOR_NO_STRICT_ALIASING} -fomit-frame-pointer"
|
|
DEBUG_OPTS="-g"
|
|
DISABLE_OPTS_OPT="-O0"
|
|
COMPILER_HALT_AT_WARN_OPT="-Werror"
|
|
COMPILER=clang
|
|
;;
|
|
msvc*)
|
|
CHECK_OPTS="-nologo" # Suppress the MSVC banner message.
|
|
OPT_OPTS="-O1"
|
|
# See README.MS-VisualC for why we don't enable C level debugging.
|
|
#DEBUG_OPTS="-Zi"
|
|
DEBUG_OPTS=""
|
|
DISABLE_OPTS_OPT="-Od"
|
|
COMPILER_HALT_AT_WARN_OPT=""
|
|
COMPILER=cl
|
|
;;
|
|
*)
|
|
CHECK_OPTS=
|
|
OPT_OPTS="-O"
|
|
DEBUG_OPTS="-g"
|
|
DISABLE_OPTS_OPT="-O0"
|
|
COMPILER_HALT_AT_WARN_OPT=""
|
|
COMPILER=unknown
|
|
;;
|
|
esac
|
|
|
|
SPLIT_OPTS=""
|
|
INLINE_ALLOC_OPTS=""
|
|
|
|
verbose=false
|
|
c_debug=false
|
|
c_optimize=true
|
|
use_activation_counts=false
|
|
preserve_tail_recursion=true
|
|
mercury_config_dir=${MERCURY_STDLIB_DIR-@LIBDIR@}
|
|
mercury_config_dir=${MERCURY_CONFIG_DIR=${mercury_config_dir}}
|
|
mercury_stdlib_dir=${MERCURY_STDLIB_DIR=@LIBDIR@}
|
|
do_filter_cc=true
|
|
halt_at_warn_if_possible=false
|
|
|
|
# include the file `init_grade_options.sh-subr'
|
|
@INIT_GRADE_OPTIONS@
|
|
|
|
Help="\
|
|
Name: mgnuc - Mercury front-end to GNU C
|
|
Usage: mgnuc [<options>] [-- <gcc options>] files...
|
|
Options:
|
|
-v, --verbose
|
|
Echo gcc command before executing it.
|
|
--no-ansi
|
|
This option is deprecatd and no longer has any effect.
|
|
--no-check
|
|
Don't enable any of gcc's warnings.
|
|
-g, --c-debug
|
|
Generate object files that can debugged with C debuggers such as gdb.
|
|
--no-c-optimize
|
|
Disable optimization by the C compiler.
|
|
--inline-alloc
|
|
Inline calls to the memory allocator.
|
|
--mercury-standard-library-directory <directory>
|
|
--mercury-stdlib-dir <directory>
|
|
The directory containing the installed Mercury standard library.
|
|
--no-mercury-standard-library-directory, --no-mercury-stdlib-dir
|
|
Don't use an installed Mercury standard library.
|
|
--no-filter-cc
|
|
Do not filter warnings from the C compiler.
|
|
--halt-at-warn-if-possible
|
|
Convert warnings into errors if (a) the C compiler supports this,
|
|
and (b) the grade is an MLDS grade. (LLDS grades get some warnings
|
|
that cannot be avoided.)
|
|
|
|
${grade_usage}
|
|
|
|
Description:
|
|
This runs gcc with the appropriate options for compiling Mercury programs.
|
|
Normally it invokes gcc with almost all warnings enabled,
|
|
but this can be changed using \`--no-check' option.
|
|
Environment variables:
|
|
MERCURY_DEFAULT_GRADE.
|
|
Files:
|
|
If the current directory contains a file named .mgnuc_copts, then mgnuc
|
|
will assume that it contains C compiler options that should be included
|
|
on the C compiler's command line. This is usually used to specify C
|
|
compiler search paths.
|
|
"
|
|
|
|
while : ; do
|
|
case "$1" in
|
|
-h|--help|"-?")
|
|
echo "${Help}"
|
|
exit 0
|
|
;;
|
|
|
|
@MGNUC_FILE_OPTS@
|
|
|
|
--mercury-standard-library-directory|--mercury-stdlib-dir)
|
|
mercury_stdlib_dir="$2"
|
|
mercury_config_dir="$2"
|
|
shift
|
|
;;
|
|
|
|
--mercury-config-directory|--mercury-config-dir)
|
|
mercury_config_dir="$2"
|
|
shift
|
|
;;
|
|
|
|
# We don't allow `MERCURY_CONFIG_DIR' to be unset
|
|
# without `MERCURY_STDLIB_DIR' also being unset.
|
|
|
|
# include the file `parse_grade_options.sh-subr'
|
|
@PARSE_GRADE_OPTIONS@
|
|
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if test -r .mgnuc_opts
|
|
then
|
|
for opt in `cat .mgnuc_opts`
|
|
do
|
|
case "${opt}" in
|
|
|
|
@MGNUC_FILE_OPTS@
|
|
|
|
*)
|
|
echo "unknown option ${opt} in .mgnuc_opts"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
fi
|
|
|
|
# include the file `final_grade_options.sh-subr'
|
|
@FINAL_GRADE_OPTIONS@
|
|
|
|
# compute the canonical grade name from the options settings
|
|
#
|
|
|
|
# include the file `canonical_grade.sh-subr'
|
|
@CANONICAL_GRADE@
|
|
|
|
case "${mercury_stdlib_dir}" in
|
|
"")
|
|
MERC_ALL_C_INCL_DIRS=
|
|
;;
|
|
*)
|
|
# The option setting code above guarantees that if
|
|
# `--mercury-stdlib-dir' is set, `--mercury-config-dir'
|
|
# is also set.
|
|
MERC_ALL_C_INCL_DIRS="-I${mercury_config_dir}/conf -I${mercury_stdlib_dir}/inc -I${mercury_stdlib_dir}/lib/${GRADE}/inc"
|
|
;;
|
|
esac
|
|
|
|
# add /usr/local/include to the default search path, if needed
|
|
ALL_LOCAL_C_INCL_DIRS=${MERCURY_ALL_LOCAL_C_INCL_DIRS=@ALL_LOCAL_C_INCL_DIRS@}
|
|
|
|
# Convert non-grade mgnuc options into gcc options.
|
|
#
|
|
# IMPORTANT: any changes here will require similar changes to
|
|
# compiler/compile_target_code.m.
|
|
|
|
case ${c_debug} in
|
|
# We set a variable named C_DEBUG_OPTS here, in the code that handles
|
|
# a -g or -cdebug-info option being given to mgnuc. Because below we handle
|
|
# the related but nevertheless separate c_debug grade component, and
|
|
# *that* code sets a variable named C_DEBUG_GRADE_OPTS.
|
|
true)
|
|
C_DEBUG_OPTS="${DEBUG_OPTS}"
|
|
# Prevent that code below from including the *original* ${DEBUG_OPTS}
|
|
# in the final list of C compiler options *again*.
|
|
DEBUG_OPTS=""
|
|
;;
|
|
false)
|
|
C_DEBUG_OPTS=""
|
|
;;
|
|
esac
|
|
|
|
case ${c_optimize} in
|
|
true) ;;
|
|
false) OPT_OPTS="" ;;
|
|
esac
|
|
|
|
# Convert grade mgnuc options into gcc options.
|
|
#
|
|
# IMPORTANT: any changes here may require similar changes to all the files
|
|
# mentioned in runtime/mercury_grade.h.
|
|
|
|
HALT_AT_WARN_OPT=""
|
|
case ${highlevel_code} in
|
|
true)
|
|
HLC_OPTS="-DMR_HIGHLEVEL_CODE"
|
|
case ${halt_at_warn_if_possible} in
|
|
true)
|
|
HALT_AT_WARN_OPT="${COMPILER_HALT_AT_WARN_OPT}"
|
|
;;
|
|
esac
|
|
;;
|
|
false)
|
|
HLC_OPTS=""
|
|
;;
|
|
esac
|
|
|
|
case ${asm_labels} in
|
|
true) ASM_OPTS="-DMR_USE_ASM_LABELS" ;;
|
|
false) ASM_OPTS="" ;;
|
|
esac
|
|
|
|
case ${non_local_gotos} in
|
|
true) GOTO_OPTS="-DMR_USE_GCC_NONLOCAL_GOTOS" ;;
|
|
false) GOTO_OPTS="" ;;
|
|
esac
|
|
|
|
case ${global_regs} in
|
|
true) REG_OPTS="-DMR_USE_GCC_GLOBAL_REGISTERS" ;;
|
|
false) REG_OPTS="" ;;
|
|
esac
|
|
|
|
case ${thread_safe} in
|
|
true)
|
|
THREAD_OPTS="-DMR_THREAD_SAFE ${CFLAGS_FOR_THREADS}"
|
|
;;
|
|
false)
|
|
THREAD_OPTS=""
|
|
;;
|
|
esac
|
|
|
|
case ${threadscope} in
|
|
true) THREADSCOPE_OPTS="-DMR_THREADSCOPE" ;;
|
|
false) THREADSCOPE_OPTS="" ;;
|
|
esac
|
|
|
|
# Set the correct flags if we're to use the MS Visual C runtime.
|
|
use_msvcrt=@USE_MSVCRT@
|
|
if test ${use_msvcrt} = "yes"; then
|
|
case ${thread_safe} in
|
|
# -MD states that we will use the MSVC runtime, the boehm_gc collector
|
|
# assumes that the collector has been built as a DLL if we are using
|
|
# the MSVC runtime so we need to define GC_NOT_DLL when the collector
|
|
# isn't built as a DLL.
|
|
true) MSVCRT_OPTS="-MD" ;;
|
|
false) MSVCRT_OPTS="-DGC_NOT_DLL -MD" ;;
|
|
esac
|
|
else
|
|
MSVCRT_OPTS=""
|
|
fi
|
|
|
|
boehm_opts="-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC "
|
|
case ${gc_method} in
|
|
accurate) GC_OPTS="-DMR_NATIVE_GC" ;;
|
|
boehm) GC_OPTS="${boehm_opts}" ;;
|
|
boehm_debug) GC_OPTS="${boehm_opts} -DMR_BOEHM_GC_DEBUG -DGC_DEBUG -DKEEP_BACK_PTRS" ;;
|
|
hgc) GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_HGC" ;;
|
|
conservative) GC_OPTS="-DMR_CONSERVATIVE_GC -DMR_BOEHM_GC" ;;
|
|
none) GC_OPTS="" ;;
|
|
esac
|
|
|
|
case ${profile_time} in
|
|
true) PROF_TIME_OPTS="-DMR_MPROF_PROFILE_TIME" ;;
|
|
false) PROF_TIME_OPTS="" ;;
|
|
esac
|
|
|
|
case ${profile_calls} in
|
|
true) PROF_CALLS_OPTS="-DMR_MPROF_PROFILE_CALLS" ;;
|
|
false) PROF_CALLS_OPTS="" ;;
|
|
esac
|
|
|
|
case ${profile_memory} in
|
|
true) PROF_MEMORY_OPTS="-DMR_MPROF_PROFILE_MEMORY" ;;
|
|
false) PROF_MEMORY_OPTS="" ;;
|
|
esac
|
|
|
|
case ${use_activation_counts} in
|
|
true) ACTIVATION_COUNT_OPT="-DMR_USE_ACTIVATION_COUNTS" ;;
|
|
false) ACTIVATION_COUNT_OPT="";;
|
|
esac
|
|
|
|
case ${preserve_tail_recursion} in
|
|
true) PRESERVE_TAIL_RECURSION_OPT="-DMR_DEEP_PROFILING_TAIL_RECURSION" ;;
|
|
false) PRESERVE_TAIL_RECURSION_OPT="";;
|
|
esac
|
|
|
|
case ${profile_deep} in
|
|
true) PROF_DEEP_OPTS="-DMR_DEEP_PROFILING ${ACTIVATION_COUNT_OPT} ${PRESERVE_TAIL_RECURSION_OPT}" ;;
|
|
false) PROF_DEEP_OPTS="" ;;
|
|
esac
|
|
|
|
case ${record_term_sizes_as_words},${record_term_sizes_as_cells} in
|
|
true,true)
|
|
progname=`basename $0`
|
|
echo "${progname}: we can't record both cell and word sizes"
|
|
exit 1
|
|
;;
|
|
true,false)
|
|
RECORD_TERM_SIZE_OPTS="-DMR_RECORD_TERM_SIZES" ;;
|
|
false,true)
|
|
RECORD_TERM_SIZE_OPTS="-DMR_RECORD_TERM_SIZES -DMR_RECORD_TERM_SIZES_AS_CELLS" ;;
|
|
false,false)
|
|
RECORD_TERM_SIZE_OPTS="" ;;
|
|
esac
|
|
|
|
case ${use_trail} in
|
|
true)
|
|
TRAIL_OPTS="-DMR_USE_TRAIL"
|
|
# See the comment in compile_c_file/7 in compiler/compile_target_code.m
|
|
# for an explanation of this.
|
|
case ${COMPILER} in
|
|
gcc) FN_ALIGN_OPTS="-falign-functions=${BYTES_PER_WORD}" ;;
|
|
*) FN_ALIGN_OPTS="" ;;
|
|
esac
|
|
;;
|
|
false)
|
|
TRAIL_OPTS=""
|
|
;;
|
|
esac
|
|
|
|
case ${use_minimal_model_stack_copy},${use_minimal_model_own_stacks} in
|
|
true,true)
|
|
progname=`basename $0`
|
|
echo "${progname}: can't enable both forms of minimal model tabling at once"
|
|
exit 1
|
|
;;
|
|
true,false)
|
|
MINIMAL_MODEL_OPTS="-DMR_USE_MINIMAL_MODEL_STACK_COPY"
|
|
;;
|
|
false,true)
|
|
MINIMAL_MODEL_OPTS="-DMR_USE_MINIMAL_MODEL_OWN_STACKS"
|
|
;;
|
|
false,false)
|
|
MINIMAL_MODEL_OPTS=""
|
|
;;
|
|
esac
|
|
|
|
case ${use_minimal_model},${minimal_model_debug} in
|
|
true,false) ;; # MINIMAL_MODEL_OPTS is already set
|
|
true,true) MINIMAL_MODEL_OPTS="${MINIMAL_MODEL_OPTS} -DMR_MINIMAL_MODEL_DEBUG" ;;
|
|
*) MINIMAL_MODEL_OPTS="" ;;
|
|
esac
|
|
|
|
case ${pregenerated_dist},${single_prec_float} in
|
|
true,true)
|
|
progname=`basename $0`
|
|
echo "${progname}: cannot enable both pregenerated dist and single-prec float"
|
|
exit 1
|
|
;;
|
|
true,false)
|
|
PREGEN_SPF_OPTS="-DMR_PREGENERATED_DIST"
|
|
;;
|
|
false,true)
|
|
PREGEN_SPF_OPTS="-DMR_USE_SINGLE_PREC_FLOAT"
|
|
;;
|
|
false,false)
|
|
PREGEN_SPF_OPTS=""
|
|
;;
|
|
esac
|
|
|
|
case ${debug} in
|
|
true) TRACE_OPTS="-DMR_EXEC_TRACE" ;;
|
|
false) TRACE_OPTS="" ;;
|
|
esac
|
|
|
|
case ${decl_debug} in
|
|
true) DECL_DEBUG_OPTS="-DMR_DECL_DEBUG" ;;
|
|
false) DECL_DEBUG_OPTS="" ;;
|
|
esac
|
|
|
|
case ${ss_debug} in
|
|
true) SS_DEBUG_OPTS="-DMR_SS_DEBUG" ;;
|
|
false) SS_DEBUG_OPTS="" ;;
|
|
esac
|
|
|
|
case ${c_debug_grade} in
|
|
true) C_DEBUG_GRADE_OPTS="-DMR_C_DEBUG_GRADE ${DEBUG_OPTS} ${DISABLE_OPTS_OPT}" ;;
|
|
false) C_DEBUG_GRADE_OPTS="" ;;
|
|
esac
|
|
|
|
case ${extend_stacks} in
|
|
true) EXTEND_STACKS_OPTS="-DMR_EXTEND_STACKS_WHEN_NEEDED" ;;
|
|
false) EXTEND_STACKS_OPTS="" ;;
|
|
esac
|
|
|
|
case ${stack_segments} in
|
|
true) STACK_SEGMENTS_OPTS="-DMR_STACK_SEGMENTS" ;;
|
|
false) STACK_SEGMENTS_OPTS="" ;;
|
|
esac
|
|
|
|
case ${use_regions} in
|
|
true)
|
|
REGION_OPTS_0="-DMR_USE_REGIONS"
|
|
case ${use_regions_debug} in
|
|
true) REGION_OPTS_1="${REGION_OPTS_0} -DMR_RBMM_DEBUG" ;;
|
|
false) REGION_OPTS_1="${REGION_OPTS_0}" ;;
|
|
esac
|
|
case ${use_regions_profiling} in
|
|
true) REGION_OPTS="${REGION_OPTS_1} -DMR_RBMM_PROFILING" ;;
|
|
false) REGION_OPTS="${REGION_OPTS_1}" ;;
|
|
esac
|
|
;;
|
|
false)
|
|
REGION_OPTS=""
|
|
;;
|
|
esac
|
|
|
|
GCC_OPTS="${ASM_OPTS} ${GOTO_OPTS} ${REG_OPTS}"
|
|
|
|
# check that special grades are only used with gcc
|
|
case ${COMPILER} in
|
|
gcc|unknown)
|
|
;;
|
|
*) case "${GCC_OPTS}" in
|
|
*USE_GCC*)
|
|
progname=`basename $0`
|
|
echo "${progname}: For compilers other than GNU C, the only" 1>&2
|
|
echo "${progname}: base grade allowed is \`none'" 1>&2
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
# if we're using global registers, add CFLAGS_FOR_REGS
|
|
case ${global_regs} in
|
|
true) GCC_OPTS="${GCC_OPTS} ${CFLAGS_FOR_REGS}" ;;
|
|
false) ;;
|
|
esac
|
|
|
|
# if we're using non-local gotos, add CFLAGS_FOR_GOTOS
|
|
case ${non_local_gotos} in
|
|
true) GCC_OPTS="${GCC_OPTS} ${CFLAGS_FOR_GOTOS}" ;;
|
|
false) ;;
|
|
esac
|
|
|
|
# if sanitizers were enabled at configure time, add CFLAGS_FOR_SANITIZERS
|
|
SANITIZER_OPTS="${CFLAGS_FOR_SANITIZERS}"
|
|
|
|
# Use any applicable LTO options
|
|
LTO_OPTS="${CFLAGS_FOR_LTO}"
|
|
|
|
#
|
|
# Special case hacks for particular architectures
|
|
# Any code here needs to be duplicated in ../configure.ac.
|
|
#
|
|
|
|
ARCH_OPTS=""
|
|
|
|
# XXX gcc generates warnings about possibly uninitialized variables in
|
|
# high-level C code. clang would, too, if we did not suppress all warnings.
|
|
case "${COMPILER},${highlevel_code}" in
|
|
gcc,true)
|
|
CHECK_OPTS="${CHECK_OPTS} -Wno-uninitialized"
|
|
;;
|
|
esac
|
|
|
|
case "${FULLARCH}" in
|
|
i*86-*|x86_64*)
|
|
# The use of stack_pointer in the ASM_JUMP macro defined in
|
|
# runtime/mercury_goto.h causes lots of warnings about using possibly
|
|
# uninitialized variables; there's no easy way to suppress them except
|
|
# by disabling the warning.
|
|
case "${COMPILER},${highlevel_code}" in
|
|
gcc,false)
|
|
CHECK_OPTS="${CHECK_OPTS} -Wno-uninitialized"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
# gcc versions 9-12 replace calls to strcmp and related functions with
|
|
# specialised code when some of the arguments are string constants.
|
|
# The above versions of gcc emit spurious warnings about the code they
|
|
# introduce when -Warray-bounds is enabled.
|
|
# We currently disable the warning for all versions of GCC > 8 since
|
|
# the problem is not known to have been fixed in any later version (as of
|
|
# 2022-06-18).
|
|
#
|
|
case "${C_COMPILER_TYPE}" in
|
|
gcc_9_*|gcc_1[0-9]_*)
|
|
CHECK_OPTS="${CHECK_OPTS} -Wno-array-bounds"
|
|
;;
|
|
esac
|
|
|
|
case ${COMPILER} in gcc)
|
|
case "${FULLARCH}" in
|
|
i*86*)
|
|
case "$*" in
|
|
# Workarounds for internal problems with GCC in asm_fast.gc
|
|
# on i*86. Reported against gcc 4.4.5 and 4.6.0.
|
|
*" ml_backend.ml_closure_gen.c "*)
|
|
ARCH_OPTS="${ARCH_OPTS} -O0"
|
|
;;
|
|
*" ml_backend.ml_unify_gen.c "*)
|
|
ARCH_OPTS="${ARCH_OPTS} -O0"
|
|
;;
|
|
*" ml_backend.rtti_to_mlds.c "*)
|
|
ARCH_OPTS="${ARCH_OPTS} -O0"
|
|
;;
|
|
*" display_report.c "*)
|
|
ARCH_OPTS="${ARCH_OPTS} -O0"
|
|
;;
|
|
# Workaround for a internal compiler error with GCC 4.8
|
|
# in grades that use global registers.
|
|
*" mercury_ho_call.c "*)
|
|
case ${global_regs} in true)
|
|
ARCH_OPTS="${ARCH_OPTS} -O0"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
# On sparc-sun-solaris2, we need to use -fPIC rather than -fpic
|
|
# because otherwise the Mercury standard library overflows the fixed limit
|
|
# on the number of "small pic" references.
|
|
# Similarly, on sparc64 OpenBSD, no grades fit into the 13-bit GOT.
|
|
|
|
case "${FULLARCH}" in
|
|
sparc-sun-solaris2*|sparc64*-openbsd*)
|
|
case "$*" in
|
|
*-fpic*)
|
|
echo "mgnuc: using -fPIC rather than -fpic"
|
|
OVERRIDE_OPTS="${OVERRIDE_OPTS} -fPIC"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
# Using global register variables triggers an internal error in the LRA pass of
|
|
# GCC 9.1 and 9.2 on x86_64 systems in debug grades unless we compile at -O0.
|
|
# See: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91430>
|
|
#
|
|
# Changes to this need to be reflected in the predicate
|
|
# gather_c_compiler_flags/3 in compiler/compile_target_code.m.
|
|
|
|
case "${FULLARCH}" in x86_64*)
|
|
case ${global_regs},${debug} in
|
|
true,true)
|
|
case "${C_COMPILER_TYPE}" in
|
|
gcc_9_*)
|
|
ARCH_OPTS="${ARCH_OPTS} -O0"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
# At -O2 compilation times on Mac OS X are extremely slow for
|
|
# Apple GCC 4.{0,2}. We must force GCC to use -O0 here in order
|
|
# to get acceptable compilation times.
|
|
# Changes to this need to be reflected in the predicate
|
|
# gather_c_compiler_flags/3 in compiler/compile_target_code.m.
|
|
|
|
case ${FULLARCH} in
|
|
*apple*darwin*)
|
|
case ${debug} in
|
|
true)
|
|
case ${COMPILER} in
|
|
gcc)
|
|
OVERRIDE_OPTS="${OVERRIDE_OPTS} -O0"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
if test -r .mgnuc_copts
|
|
then
|
|
INVISIBLE_OPTS=`cat .mgnuc_copts`
|
|
else
|
|
INVISIBLE_OPTS=""
|
|
fi
|
|
|
|
FILTERCC=""
|
|
case ${asm_labels},${do_filter_cc} in
|
|
true,true)
|
|
# Check if mfiltercc is available as we may be bootstrapping with
|
|
# an older compiler which did not have it.
|
|
if test -n "${MKTEMP}" && mfiltercc </dev/null 2>/dev/null
|
|
then
|
|
FILTERCC="mfiltercc"
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
ALL_CC_OPTS="${MERC_ALL_C_INCL_DIRS}\
|
|
${CHECK_OPTS}\
|
|
${OPT_OPTS}\
|
|
${LTO_OPTS}\
|
|
${HLC_OPTS}\
|
|
${GCC_OPTS}\
|
|
${HALT_AT_WARN_OPT}\
|
|
${MSVCRT_OPTS}\
|
|
${GC_OPTS}\
|
|
${DEFINE_OPTS}\
|
|
${STACK_TRACE_OPTS}\
|
|
${TRACE_OPTS}\
|
|
${DECL_DEBUG_OPTS}\
|
|
${SS_DEBUG_OPTS}\
|
|
${C_DEBUG_GRADE_OPTS}\
|
|
${EXTEND_STACKS_OPTS}\
|
|
${STACK_SEGMENTS_OPTS}\
|
|
${C_DEBUG_OPTS}\
|
|
${PROF_TIME_OPTS}\
|
|
${PROF_CALLS_OPTS}\
|
|
${PROF_MEMORY_OPTS}\
|
|
${PROF_DEEP_OPTS}\
|
|
${INLINE_ALLOC_OPTS}\
|
|
${TRAIL_OPTS}\
|
|
${RECORD_TERM_SIZE_OPTS}\
|
|
${MINIMAL_MODEL_OPTS}\
|
|
${PREGEN_SPF_OPTS}\
|
|
${SANITIZER_OPTS}\
|
|
${SPLIT_OPTS}\
|
|
${THREAD_OPTS}\
|
|
${THREADSCOPE_OPTS}\
|
|
${REGION_OPTS}\
|
|
${ARCH_OPTS}\
|
|
${FN_ALIGN_OPTS}\
|
|
${INVISIBLE_OPTS}"
|
|
|
|
case $# in
|
|
0)
|
|
set ${CC} ${ALL_CC_OPTS} ${OVERRIDE_OPTS}
|
|
;;
|
|
*)
|
|
set ${CC} ${ALL_CC_OPTS} "$@" ${OVERRIDE_OPTS} ${ALL_LOCAL_C_INCL_DIRS}
|
|
;;
|
|
esac
|
|
|
|
case ${verbose} in
|
|
true)
|
|
echo "$@"
|
|
;;
|
|
esac
|
|
|
|
if test -z "${FILTERCC}"
|
|
then
|
|
exec "$@"
|
|
fi
|
|
|
|
# mktemp should give its own error message.
|
|
tmp=`${MKTEMP} ${TMPDIR}/mgnuc.XXXXXX` || exit 1
|
|
trap 'status=$?; rm -f ${tmp}; exit ${status}' 0 1 2 3 13 15
|
|
"$@" 2> ${tmp}
|
|
status=$?
|
|
"${FILTERCC}" < ${tmp} >&2
|
|
exit ${status}
|