@@ -277,10 +277,15 @@ function float_min() {
277
277
function num_llvm_parallel_lto_link_jobs() {
278
278
case " $( uname -s -m) " in
279
279
Darwin\ x86_64)
280
- # Currently with -gline-tables-only clang is ~3.5GB on Darwin. Use
281
- # the formula GB Memory/3.5GB to get the number of parallel link
282
- # threads we can support.
283
- local NUM_MEMORY_THREADS=$( echo $( system_memory_in_bytes) /1000000000.0/3.5 | bc)
280
+ # *WARNING! HUERISTIC!*
281
+ #
282
+ # Use the formula (GB Memory - 3)/6.0GB to get the number of
283
+ # parallel link threads we can support. This gives the OS 3 GB of
284
+ # room to work with.
285
+ #
286
+ # This is a bit conservative, but I have found that this number
287
+ # prevents me from swapping on my test machine.
288
+ local NUM_MEMORY_THREADS=$( echo \( $( system_memory_in_bytes) /1000000000.0 - 3.0 \) / 6.0 | bc)
284
289
echo $( float_min " ${NUM_MEMORY_THREADS} " " ${BUILD_JOBS} " )
285
290
;;
286
291
* )
@@ -293,10 +298,15 @@ function num_llvm_parallel_lto_link_jobs() {
293
298
function num_swift_parallel_lto_link_jobs() {
294
299
case " $( uname -s -m) " in
295
300
Darwin\ x86_64)
296
- # Currently with -gline-tables-only swift is ~5-6GB on Darwin. Use
297
- # the formula GB Memory/6GB to get the number of parallel link
298
- # threads we can support.
299
- local NUM_MEMORY_THREADS=$( echo $( system_memory_in_bytes) /1000000000/6.0 | bc)
301
+ # *WARNING! HUERISTIC!*
302
+ #
303
+ # Use the formula (GB Memory - 3)/8.0GB to get the number of
304
+ # parallel link threads we can support. This gives the OS 3 GB of
305
+ # room to work with.
306
+ #
307
+ # This is a bit conservative, but I have found that this number
308
+ # prevents me from swapping on my test machine.
309
+ local NUM_MEMORY_THREADS=$( echo \( $( system_memory_in_bytes) /1000000000 - 3.0 \) / 8.0 | bc)
300
310
echo $( float_min " ${NUM_MEMORY_THREADS} " " ${BUILD_JOBS} " )
301
311
;;
302
312
* )
@@ -531,10 +541,6 @@ function set_deployment_target_based_options() {
531
541
fi
532
542
533
543
llvm_cmake_options+=(
534
- " -DCMAKE_C_FLAGS=-O2 -flto -gline-tables-only -fno-stack-protector "
535
- " -DCMAKE_CXX_FLAGS=-O2 -flto -gline-tables-only -fno-stack-protector "
536
- " -DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -flto -gline-tables-only -fno-stack-protector "
537
- " -DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -flto -gline-tables-only -fno-stack-protector "
538
544
" -DLLVM_PARALLEL_LINK_JOBS=$( num_llvm_parallel_lto_link_jobs) "
539
545
)
540
546
fi
@@ -1239,6 +1245,9 @@ function llvm_c_flags() {
1239
1245
if [[ $( is_cmake_release_build_type " ${LLVM_BUILD_TYPE} " ) ]] ; then
1240
1246
echo -n " -fno-stack-protector"
1241
1247
fi
1248
+ if [[ $( true_false " ${LLVM_ENABLE_LTO} " ) ]] ; then
1249
+ echo -n " -gline-tables-only"
1250
+ fi
1242
1251
}
1243
1252
1244
1253
function cmark_c_flags() {
@@ -1527,6 +1536,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
1527
1536
-DLLVM_TARGETS_TO_BUILD=" ${LLVM_TARGETS_TO_BUILD} "
1528
1537
-DLLVM_INCLUDE_TESTS:BOOL=$( true_false " ${SOURCE_TREE_INCLUDES_TESTS} " )
1529
1538
-DLLVM_INCLUDE_DOCS:BOOL=TRUE
1539
+ -DLLVM_ENABLE_LTO=$( true_false " ${LLVM_ENABLE_LTO} " )
1530
1540
" ${llvm_cmake_options[@]} "
1531
1541
)
1532
1542
if [[ $( is_cross_tools_deployment_target ${deployment_target} ) ]] ; then
@@ -1619,6 +1629,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
1619
1629
-DCMAKE_CXX_FLAGS=" $( swift_c_flags ${deployment_target} ) "
1620
1630
-DCMAKE_BUILD_TYPE:STRING=" ${SWIFT_BUILD_TYPE} "
1621
1631
-DLLVM_ENABLE_ASSERTIONS:BOOL=$( true_false " ${SWIFT_ENABLE_ASSERTIONS} " )
1632
+ -DLLVM_ENABLE_LTO=$( true_false " ${LLVM_ENABLE_LTO} " )
1622
1633
-DSWIFT_ANALYZE_CODE_COVERAGE:STRING=$( toupper " ${SWIFT_ANALYZE_CODE_COVERAGE} " )
1623
1634
-DSWIFT_STDLIB_BUILD_TYPE:STRING=" ${SWIFT_STDLIB_BUILD_TYPE} "
1624
1635
-DSWIFT_STDLIB_ASSERTIONS:BOOL=$( true_false " ${SWIFT_STDLIB_ENABLE_ASSERTIONS} " )
0 commit comments