| 110 --debug add extra compile flags for debug builds |
110 --debug add extra compile flags for debug builds |
| 111 --release add extra compile flags for release builds |
111 --release add extra compile flags for release builds |
| 112 |
112 |
| 113 Optional Features: |
113 Optional Features: |
| 114 --enable-static statically link libstdc++ |
114 --enable-static statically link libstdc++ |
| |
115 --enable-asan compile with address sanitizer |
| |
116 --enable-ubsan compile with undefined behavior sanitizer |
| 115 |
117 |
| 116 __EOF__ |
118 __EOF__ |
| 117 } |
119 } |
| 118 |
120 |
| 119 # create temporary directory |
121 # create temporary directory |
| 177 "--help"*) printhelp; abort_configure ;; |
179 "--help"*) printhelp; abort_configure ;; |
| 178 "--debug") BUILD_TYPE="debug" ;; |
180 "--debug") BUILD_TYPE="debug" ;; |
| 179 "--release") BUILD_TYPE="release" ;; |
181 "--release") BUILD_TYPE="release" ;; |
| 180 "--enable-static") FEATURE_STATIC=on ;; |
182 "--enable-static") FEATURE_STATIC=on ;; |
| 181 "--disable-static") unset FEATURE_STATIC ;; |
183 "--disable-static") unset FEATURE_STATIC ;; |
| |
184 "--enable-asan") FEATURE_ASAN=on ;; |
| |
185 "--disable-asan") unset FEATURE_ASAN ;; |
| |
186 "--enable-ubsan") FEATURE_UBSAN=on ;; |
| |
187 "--disable-ubsan") unset FEATURE_UBSAN ;; |
| 182 "-"*) echo "unknown option: $ARG"; abort_configure ;; |
188 "-"*) echo "unknown option: $ARG"; abort_configure ;; |
| 183 esac |
189 esac |
| 184 done |
190 done |
| 185 |
191 |
| 186 |
192 |
| 293 shift |
299 shift |
| 294 printf "$@" |
300 printf "$@" |
| 295 fi |
301 fi |
| 296 } |
302 } |
| 297 |
303 |
| |
304 dependency_error_asan() |
| |
305 { |
| |
306 print_check_msg "$dep_checked_asan" "checking for asan... " |
| |
307 # dependency asan toolchain="gnuc" |
| |
308 while true |
| |
309 do |
| |
310 if notistoolchain "gnuc"; then |
| |
311 break |
| |
312 fi |
| |
313 TEMP_CXXFLAGS="$TEMP_CXXFLAGS -fsanitize=address" |
| |
314 TEMP_LDFLAGS="$TEMP_LDFLAGS -fsanitize=address" |
| |
315 print_check_msg "$dep_checked_asan" "yes\n" |
| |
316 dep_checked_asan=1 |
| |
317 return 1 |
| |
318 done |
| |
319 |
| |
320 print_check_msg "$dep_checked_asan" "no\n" |
| |
321 dep_checked_asan=1 |
| |
322 return 0 |
| |
323 } |
| 298 dependency_error_static() |
324 dependency_error_static() |
| 299 { |
325 { |
| 300 print_check_msg "$dep_checked_static" "checking for static... " |
326 print_check_msg "$dep_checked_static" "checking for static... " |
| 301 # dependency static toolchain="gcc" |
327 # dependency static toolchain="gnuc" |
| 302 while true |
328 while true |
| 303 do |
329 do |
| 304 if notistoolchain "gcc"; then |
330 if notistoolchain "gnuc"; then |
| 305 break |
331 break |
| 306 fi |
332 fi |
| 307 TEMP_LDFLAGS="$TEMP_LDFLAGS -static" |
333 TEMP_LDFLAGS="$TEMP_LDFLAGS -static" |
| 308 print_check_msg "$dep_checked_static" "yes\n" |
334 print_check_msg "$dep_checked_static" "yes\n" |
| 309 dep_checked_static=1 |
335 dep_checked_static=1 |
| 310 return 1 |
336 return 1 |
| 311 done |
337 done |
| 312 |
338 |
| 313 # dependency static toolchain="clang" |
|
| 314 while true |
|
| 315 do |
|
| 316 if notistoolchain "clang"; then |
|
| 317 break |
|
| 318 fi |
|
| 319 TEMP_LDFLAGS="$TEMP_LDFLAGS -static" |
|
| 320 print_check_msg "$dep_checked_static" "yes\n" |
|
| 321 dep_checked_static=1 |
|
| 322 return 1 |
|
| 323 done |
|
| 324 |
|
| 325 print_check_msg "$dep_checked_static" "no\n" |
339 print_check_msg "$dep_checked_static" "no\n" |
| 326 dep_checked_static=1 |
340 dep_checked_static=1 |
| |
341 return 0 |
| |
342 } |
| |
343 dependency_error_ubsan() |
| |
344 { |
| |
345 print_check_msg "$dep_checked_ubsan" "checking for ubsan... " |
| |
346 # dependency ubsan toolchain="gnuc" |
| |
347 while true |
| |
348 do |
| |
349 if notistoolchain "gnuc"; then |
| |
350 break |
| |
351 fi |
| |
352 TEMP_CXXFLAGS="$TEMP_CXXFLAGS -fsanitize=undefined" |
| |
353 TEMP_LDFLAGS="$TEMP_LDFLAGS -fsanitize=undefined" |
| |
354 print_check_msg "$dep_checked_ubsan" "yes\n" |
| |
355 dep_checked_ubsan=1 |
| |
356 return 1 |
| |
357 done |
| |
358 |
| |
359 print_check_msg "$dep_checked_ubsan" "no\n" |
| |
360 dep_checked_ubsan=1 |
| 327 return 0 |
361 return 0 |
| 328 } |
362 } |
| 329 |
363 |
| 330 # start collecting dependency information |
364 # start collecting dependency information |
| 331 echo > "$TEMP_DIR/flags.mk" |
365 echo > "$TEMP_DIR/flags.mk" |
| 408 if [ -n "$FEATURE_STATIC" ]; then |
442 if [ -n "$FEATURE_STATIC" ]; then |
| 409 : |
443 : |
| 410 else |
444 else |
| 411 : |
445 : |
| 412 fi |
446 fi |
| |
447 if [ -n "$FEATURE_ASAN" ]; then |
| |
448 # check dependency |
| |
449 if dependency_error_asan ; then |
| |
450 # "auto" features can fail and are just disabled in this case |
| |
451 if [ "$FEATURE_ASAN" = "auto" ]; then |
| |
452 DISABLE_FEATURE_ASAN=1 |
| |
453 else |
| |
454 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED asan " |
| |
455 ERROR=1 |
| |
456 fi |
| |
457 fi |
| |
458 if [ -n "$DISABLE_FEATURE_ASAN" ]; then |
| |
459 unset FEATURE_ASAN |
| |
460 fi |
| |
461 fi |
| |
462 if [ -n "$FEATURE_ASAN" ]; then |
| |
463 : |
| |
464 else |
| |
465 : |
| |
466 fi |
| |
467 if [ -n "$FEATURE_UBSAN" ]; then |
| |
468 # check dependency |
| |
469 if dependency_error_ubsan ; then |
| |
470 # "auto" features can fail and are just disabled in this case |
| |
471 if [ "$FEATURE_UBSAN" = "auto" ]; then |
| |
472 DISABLE_FEATURE_UBSAN=1 |
| |
473 else |
| |
474 DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ubsan " |
| |
475 ERROR=1 |
| |
476 fi |
| |
477 fi |
| |
478 if [ -n "$DISABLE_FEATURE_UBSAN" ]; then |
| |
479 unset FEATURE_UBSAN |
| |
480 fi |
| |
481 fi |
| |
482 if [ -n "$FEATURE_UBSAN" ]; then |
| |
483 : |
| |
484 else |
| |
485 : |
| |
486 fi |
| 413 |
487 |
| 414 |
488 |
| 415 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
489 if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then |
| 416 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
490 echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" |
| 417 fi |
491 fi |