Fix three hwloc related build system problems, these were raised in code

reviews.

The configure script now supports the --without-hwloc option to disable the use
of hwloc, even if it is installed.

configure.in:
    Allow the use of libhwloc to be disabled with the --without-hwloc option.

Distribute the autoconf macros for pkg-config with Mercury.

This allows mercury to be compiled from CVS on hosts that don't have these
macros in their autoconf installation.

acinclude.m4:
m4/mercury.m4:
    Moved acinclude.m4 to m4/mercury.m4.  This file contains mercury-specific
    macros.

m4/pkg.m4:
    Copied pkg.m4 from the autoconf installation on taura.  This file contains
    pkg-config macros.

INSTALL_CVS:
Mmakefile:
tools/test_mercury:
    When calling aclocal pass the -I m4 option.

tools/bootcheck:
    Create a link to the m4 directory when setting up stage directories.

Fix static linking with mmc --make and hwloc.

compiler/compile_target_code.m:
    Conform to changes in scripts/ml.in (where static linking and hwloc is
    already handled correctly).

compiler/options.m:
    Create new options so that Mercury.config can tell mmc what options are
    needed for linking to hwloc.

scripts/Mercury.config:
    Pass hwloc linking options to the compiler.
This commit is contained in:
Paul Bone
2011-11-08 02:22:42 +00:00
parent b060797cf7
commit bc92fb14b1
10 changed files with 229 additions and 26 deletions

View File

@@ -40,7 +40,7 @@
parallel=-j3
aclocal &&
aclocal -I m4 &&
autoconf &&
./configure &&
touch Mmake.params &&

View File

@@ -370,8 +370,8 @@ cleanint:
#-----------------------------------------------------------------------------#
aclocal.m4: configure.in acinclude.m4
aclocal
aclocal.m4: configure.in $(wildcard m4/*.m4)
aclocal -I m4
configure: configure.in aclocal.m4
autoconf

View File

@@ -1894,10 +1894,29 @@ link_exe_or_shared_lib(Globals, ErrorStream, LinkTargetType, ModuleName,
use_thread_libs(Globals, UseThreadLibs),
(
UseThreadLibs = yes,
globals.lookup_string_option(Globals, ThreadFlagsOpt, ThreadOpts)
globals.lookup_string_option(Globals, ThreadFlagsOpt, ThreadOpts),
% Determine which options are needed to link to libhwloc, if libhwloc
% is used at all.
globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode),
(
HighLevelCode = yes,
HwlocOpts = ""
;
HighLevelCode = no,
( Linkage = "shared" ->
HwlocFlagsOpt = hwloc_libs
; Linkage = "static" ->
HwlocFlagsOpt = hwloc_static_libs
;
unexpected($module, $pred, "Invalid linkage")
),
globals.lookup_string_option(Globals, HwlocFlagsOpt, HwlocOpts)
)
;
UseThreadLibs = no,
ThreadOpts = ""
ThreadOpts = "",
HwlocOpts = ""
),
% Find the Mercury standard libraries.
@@ -2014,6 +2033,7 @@ link_exe_or_shared_lib(Globals, ErrorStream, LinkTargetType, ModuleName,
LDFlags, " ",
LinkLibraries, " ",
MercuryStdLibs, " ",
HwlocOpts, " ",
SystemLibs], LinkCmd),
globals.lookup_bool_option(Globals, demangle, Demangle),

View File

@@ -918,6 +918,8 @@
; filtercc_command
; trace_libs
; thread_libs
; hwloc_libs
; hwloc_static_libs
; shared_libs
; math_lib
; readline_libs
@@ -1801,6 +1803,8 @@ option_defaults_2(link_option, [
filtercc_command - string("mfiltercc"),
trace_libs - string(""),
thread_libs - string(""),
hwloc_libs - string(""),
hwloc_static_libs - string(""),
shared_libs - string(""),
math_lib - string(""),
readline_libs - string(""),
@@ -2748,6 +2752,8 @@ long_option("demangle-command", demangle_command).
long_option("filtercc-command", filtercc_command).
long_option("trace-libs", trace_libs).
long_option("thread-libs", thread_libs).
long_option("hwloc-libs", hwloc_libs).
long_option("hwloc-static-libs", hwloc_static_libs).
long_option("shared-libs", shared_libs).
long_option("math-lib", math_lib).
long_option("readline-libs", readline_libs).
@@ -5591,6 +5597,7 @@ options_help_link -->
% --mkinit-command, --demangle-command, --filtercc-command,
% --trace-libs,
% --thread-libs, --shared-libs, --math-lib, --readline-libs,
% --hwloc-libs, --hwloc-static-libs,
% --linker-opt-separator,
% --linker-debug-flags, --shlib-linker-debug-flags,
% --linker-trace-flags, --shlib-linker-trace-flags,

View File

@@ -5111,22 +5111,37 @@ MERCURY_CHECK_READLINE
# Check for libhwloc, http://www.open-mpi.org/projects/hwloc/
#
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(libhwloc, hwloc >= 1.0,
[
AC_DEFINE(MR_HAVE_HWLOC)
hwloc_static_libs="`pkg-config --libs --static hwloc`"
],
[
case "$LIBGRADES" in
$BEST_LLDS_BASE_GRADE.par.gc*)
MERCURY_MSG(["Warning: libhwloc not found, thread pinning in"])
MERCURY_MSG(["low-level C parallel grades may be less accurate."])
;;
*)
;;
esac
hwloc_static_libs=""
])
AC_ARG_WITH([hwloc],
[AS_HELP_STRING([--without-hwloc],
[Do not use libhwloc to detect the processors available in low-level C
parallel grades.])],
[],
[with_hwloc=check])
if test "$with_hwloc" != "no"; then
PKG_CHECK_MODULES(libhwloc, hwloc >= 1.0,
[
AC_DEFINE(MR_HAVE_HWLOC)
hwloc_static_libs="`pkg-config --libs --static hwloc`"
],
[
case "$LIBGRADES" in
$BEST_LLDS_BASE_GRADE.par.gc*)
MERCURY_MSG(["Warning: libhwloc not found, thread pinning in"])
MERCURY_MSG(["low-level C parallel grades may be less accurate."])
;;
*)
;;
esac
hwloc_static_libs=""
])
else
libhwloc_LIBS=""
libhwloc_CFLAGS=""
libhwloc_static_libs=""
fi
HWLOC_LIBS="$libhwloc_LIBS"
HWLOC_CFLAGS="$libhwloc_CFLAGS"
HWLOC_STATIC_LIBS="$hwloc_static_libs"

157
m4/pkg.m4 Normal file
View File

@@ -0,0 +1,157 @@
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 1 (pkg-config-0.24)
#
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])# PKG_PROG_PKG_CONFIG
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
# only at the first occurence in configure.ac, so if the first place
# it's called might be skipped (such as if it is within an "if", you
# have to call PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
# ---------------------------------------------
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])# _PKG_CONFIG
# _PKG_SHORT_ERRORS_SUPPORTED
# -----------------------------
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])# _PKG_SHORT_ERRORS_SUPPORTED
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])# PKG_CHECK_MODULES

View File

@@ -4,7 +4,7 @@
#
# @configure_input@
#---------------------------------------------------------------------------#
# Copyright (C) 2003-2007, 2010 The University of Melbourne.
# Copyright (C) 2003-2007, 2010-2011 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#
@@ -85,6 +85,8 @@ DEFAULT_MCFLAGS=\
--link-shared-lib-command "@LINK_SHARED_OBJ@" \
--trace-libs "@TRACE_BASE_LIBS_SYSTEM@" \
--thread-libs "@THREAD_LIBS@" \
--hwloc-libs "@HWLOC_LIBS@" \
--hwloc-static-libs "@HWLOC_STATIC_LIBS@" \
--shared-libs "@SHARED_LIBS@" \
--math-lib "@MATH_LIB@" \
--readline-libs "@READLINE_LIBRARIES@" \

View File

@@ -835,7 +835,8 @@ then
$LN_S $root/deep_profiler .
fi
$LN_S $root/conf* .
$LN_S $root/ac*.m4 .
$LN_S $root/aclocal.m4 .
$LN_S $root/m4 .
$LN_S $root/VERSION .
$LN_S $root/install-sh .
$LN_S $root/.*.in .
@@ -1235,7 +1236,8 @@ then
$LN_S $root/$stage2dir/profiler .
$LN_S $root/$stage2dir/deep_profiler .
$LN_S $root/conf* .
$LN_S $root/ac*.m4 .
$LN_S $root/aclocal.m4 .
$LN_S $root/m4 .
$LN_S $root/VERSION .
$LN_S $root/install-sh .
$LN_S $root/.*.in .

View File

@@ -735,7 +735,7 @@ esac
# XXX building the depend target in parallel sometimes fails so we don't
# do that at the moment - it's probably not worth doing anyway.
#
aclocal || { false; exit 1; }
aclocal -I m4 || { false; exit 1; }
autoconf || { false; exit 1; }
rm -f config.cache
./configure --prefix=$INSTALL_DIR $CONFIG_OPTS || { false; exit 1; }
@@ -863,7 +863,7 @@ case $HOST in $ROTD_HOST)
: > Mmake.params &&
rm -f so_locations &&
rm -f .enable_lib_grades &&
aclocal &&
aclocal -I m4 &&
autoconf &&
mercury_cv_low_tag_bits=2 \
mercury_cv_bits_per_word=32 \