You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Check if we have an optimization argument already
94
-
optimization_applied=0
94
+
#optimization flag added as a command-line argument
95
+
optimization_flag=""
95
96
96
-
#Check if we have -std=c++X or --std=c++X already
97
-
stdcxx_applied=0
97
+
#std standard flag added as a command-line argument
98
+
std_flag=""
98
99
99
100
# Run nvcc a second time to generate dependencies if needed
100
101
depfile_separate=0
@@ -104,6 +105,10 @@ depfile_target_arg=""
104
105
# Option to remove duplicate libraries and object files
105
106
remove_duplicate_link_files=0
106
107
108
+
functionwarn_std_flag() {
109
+
echo"nvcc_wrapper - *warning* you have set multiple standard flags (-std=c++1* or --std=c++1*), only the last is used because nvcc can only accept a single std setting"> /dev/null
110
+
}
111
+
107
112
#echo "Arguments: $# $@"
108
113
109
114
while [ $#-gt 0 ]
@@ -135,12 +140,16 @@ do
135
140
;;
136
141
# Ensure we only have one optimization flag because NVCC doesn't allow muliple
137
142
-O*)
138
-
if [ $optimization_applied-eq 1 ];then
139
-
echo"nvcc_wrapper - *warning* you have set multiple optimization flags (-O*), only the first is used because nvcc can only accept a single optimization setting."> /dev/null
143
+
if [ -n"$optimization_flag" ];then
144
+
echo"nvcc_wrapper - *warning* you have set multiple optimization flags (-O*), only the last is used because nvcc can only accept a single optimization setting."> /dev/null
145
+
shared_args=${shared_args/$optimization_flag/}
146
+
fi
147
+
if [ "$1"="-O" ];then
148
+
optimization_flag="-O2"
140
149
else
141
-
shared_args="$shared_args$1"
142
-
optimization_applied=1
150
+
optimization_flag=$1
143
151
fi
152
+
shared_args="$shared_args$optimization_flag"
144
153
;;
145
154
#Handle shared args (valid for both nvcc and the host compiler)
echo"nvcc_wrapper - *warning* you have set multiple optimization flags (-std=c++1* or --std=c++1*), only the first is used because nvcc can only accept a single std setting"> /dev/null
# this is hopefully just occurring in a downstream project during CMake feature tests
207
+
# we really have no choice here but to accept the flag and change to an accepted C++ standard
208
+
echo"nvcc_wrapper does not accept standard flags $1 since partial standard flags and standards after C++14 are not supported. nvcc_wrapper will use $fallback_std_flag instead. It is undefined behavior to use this flag. This should only be occurring during CMake configuration."
209
+
if [ -n"$std_flag" ];then
210
+
warn_std_flag
211
+
shared_args=${shared_args/$std_flag/}
212
+
fi
213
+
std_flag=$fallback_std_flag
214
+
shared_args="$shared_args$std_flag"
215
+
;;
216
+
-std=gnu*)
217
+
corrected_std_flag=${1/gnu/c}
218
+
echo"nvcc_wrapper has been given GNU extension standard flag $1 - reverting flag to $corrected_std_flag"
219
+
if [ -n"$std_flag" ];then
220
+
warn_std_flag
221
+
shared_args=${shared_args/$std_flag/}
222
+
fi
223
+
std_flag=$corrected_std_flag
224
+
shared_args="$shared_args$std_flag"
225
+
;;
226
+
--std=c++11|-std=c++11|--std=c++14|-std=c++14)
227
+
if [ -n"$std_flag" ];then
228
+
warn_std_flag
229
+
shared_args=${shared_args/$std_flag/}
201
230
fi
231
+
std_flag=$1
232
+
shared_args="$shared_args$std_flag"
202
233
;;
203
234
204
235
#strip of -std=c++98 due to nvcc warnings and Tribits will place both -std=c++11 and -std=c++98
@@ -313,16 +344,6 @@ do
313
344
shift
314
345
done
315
346
316
-
#Check if nvcc exists
317
-
if [ $host_only-ne 1 ];then
318
-
var=$(which nvcc )
319
-
if [ $?-gt 0 ];then
320
-
echo"Could not find nvcc in PATH"
321
-
exit$?
322
-
fi
323
-
fi
324
-
325
-
326
347
# Only print host compiler version
327
348
if [ $get_host_version-eq 1 ];then
328
349
$host_compiler --version
@@ -377,6 +398,9 @@ if [ $first_xcompiler_arg -eq 0 ]; then
0 commit comments