Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Workaround for errors given by Asan (certainly false positives).
[simgrid.git] / src / smpi / smpicxx.in
1 #!/usr/bin/env sh
2
3 # Copyright (c) 2014-2020. The SimGrid Team.
4 # All rights reserved.
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
8
9 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
10 SIMGRID_GITHASH="@SIMGRID_GITHASH@"
11
12 CXX=@CMAKE_CXX_COMPILER@
13
14 INCLUDEARGS="@includeflag@"
15 CMAKE_LINKARGS="-L@libdir@"
16
17 @SMPITOOLS_SH@
18
19 list_set CXXFLAGS "-std=gnu++11" @SMPI_CXX_FLAGS@
20 list_set LINKARGS
21 if [ "@WIN32@" != "1" ]; then
22     list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
23     list_add CXXFLAGS "-fPIC"
24     if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
25        list_add LINKARGS "-shared"
26     else
27        echo "Warning: smpicxx pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
28     fi
29     list_add LINKARGS "-lsimgrid"
30 else
31     list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_main.h"
32     list_add LINKARGS "@libdir@\libsimgrid.dll"
33 fi
34
35 list_set CMDARGS
36 while [ $# -gt 0 ]; do
37     ARG="$1"
38     shift
39     case "${ARG}" in
40         -c)
41             CMAKE_LINKARGS=""
42             LINKARGS=""
43             list_add CMDARGS "-c"
44             ;;
45         *.c)
46             SRCFILE="$(readlink -f ${ARG} 2>/dev/null)"
47             if [ -z "$SRCFILE" ] ; then
48                 SRCFILE="$ARG"
49             fi
50             list_add CMDARGS "${SRCFILE}"
51             ;;
52         '-version' | '--version')
53             printf '%b\n' "$SIMGRID_VERSION"
54             exit 0
55             ;;
56         "-git-version" | "--git-version")
57             printf '%b\n' "$SIMGRID_GITHASH"
58             exit 0
59             ;;
60         '-compiler-version' | '--compiler-version')
61             ${CXX} --version
62             ;;
63         '-show'|'-compile-info'|'-link-info')
64             # Dry run displaying commands instead of executing them. Useful to cmake
65             show=1
66             ;;
67         *)
68             list_add CMDARGS "${ARG}"
69       ;;
70   esac
71 done
72
73 list_set CMDLINE "${CXX}"
74 list_add_not_empty CMDLINE "${CXXFLAGS}"
75 list_add_not_empty CMDLINE ${INCLUDEARGS}
76 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
77 list_add_not_empty CMDLINE "${CMDARGS}"
78 list_add_not_empty CMDLINE "${LINKARGS}"
79
80 eval $(list_get CMDLINE)
81 if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
82   echo "$@"
83   [ "x$show" = x1 ] && exit 0
84 fi
85 "$@"