forked from coin-or-tools/BuildTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.patch
98 lines (97 loc) · 2.48 KB
/
compile.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
--- compile
+++ compile
@@ -133,6 +133,9 @@ func_cl_wrapper ()
lib_path=
shared=:
linker_opts=
+ outfile=
+ implib=
+ linking=1
for arg
do
if test -n "$eat"; then
@@ -147,11 +150,13 @@ func_cl_wrapper ()
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
+ outfile="$file"
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
+ outfile="$file"
;;
esac
;;
@@ -193,6 +198,7 @@ func_cl_wrapper ()
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
+ case "$flag" in -IMPLIB:*) implib=${flag#-IMPLIB:} ;; esac
done
IFS="$save_ifs"
;;
@@ -200,6 +206,10 @@ func_cl_wrapper ()
eat=1
linker_opts="$linker_opts $2"
;;
+ -std=*)
+ set x "$@" -std:"${1#-std=}"
+ shift
+ ;;
-*)
set x "$@" "$1"
shift
@@ -214,6 +224,11 @@ func_cl_wrapper ()
set x "$@" "$file"
shift
;;
+ -c)
+ linking=0
+ set x "$@" "$1"
+ shift
+ ;;
*)
set x "$@" "$1"
shift
@@ -225,8 +240,28 @@ func_cl_wrapper ()
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
- exec "$@" $linker_opts
- exit 1
+ # remove old $implib, so we can distinguish between generated and not-generated implib below
+ if test -n "$implib" && test -f "$implib" ; then rm "$implib" ; fi
+
+ # add path to MSVC link in front on PATH if we seem to link (check isn't so accurate, but some false-positives shouldn't matter)
+ # compiler will call the link it finds in the PATH, and we don't want it to use MSYS' /bin/link
+ # we assume that MSVC link is in same directory as cl and that cl is found in PATH
+ if test "$linking" = 1 && comppath=`which cl 2>/dev/null` ; then
+ comppath=`dirname "$comppath"`
+ #echo "Adding $comppath to front of PATH"
+ PATH="$comppath:$PATH"
+ fi
+
+ #echo "compile: $@ $linker_opts"
+ "$@" $linker_opts || exit $?
+
+ # if -implib got lost or ignored, then the lib should be named ${outfile/.dll/.lib} and we rename that file
+ if test -n "$implib" && test ! -f "$implib" ; then
+ echo "compile: mv ${outfile/.dll/.lib} $implib"
+ mv "${outfile/.dll/.lib}" "$implib"
+ fi
+
+ exit 0
}
eat=
@@ -256,7 +291,8 @@ EOF
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
- icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
+ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe | \
+ ifort | *[/\\]ifort | ifort.exe | *[/\\]ifort.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac