From 52f975fb8b24545cfe8c807fbf3a652dfe70984d Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 24 Aug 2021 21:42:38 -0700 Subject: [PATCH] fix some bugs with new build script --- bin/bld_core.sh | 50 +++++++++++++++++++++++++------------------- bin/build_tests.sh | 2 +- bin/linker_flags.txt | 8 ++++++- source/md.c | 2 +- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/bin/bld_core.sh b/bin/bld_core.sh index f29c7f4..d2b8b66 100644 --- a/bin/bld_core.sh +++ b/bin/bld_core.sh @@ -198,16 +198,6 @@ function bld_compile { local file_base_no_ext=${file_base%.*} local out_file="$file_base_no_ext$dot_ext_obj" - ###### diagnostic output ################################################## - if [ "$diagnostics" == "1" ]; then - echo "cmp $final_in_file -- ${all_opts[@]}" - fi - - ###### print source file (if the compiler doesn't do it automatically) #### - if [ "$manually_print_target" == "1" ]; then - echo "$file_base" - fi - ###### get real flags ##################################################### local flags_file=$bin_path/compiler_flags.txt local flags=$(bld_flags_from_opts $flags_file ${all_opts[@]}) @@ -220,8 +210,21 @@ function bld_compile { rm -f "$out_file_base.o" rm -f "$out_file_base.obj" - ###### compile ############################################################ + ###### get flags ########################################################## local all_flags="-c -I$src_path ${flags}" + + ###### diagnostic output ################################################## + if [ "$diagnostics" == "1" ]; then + echo "cmp $final_in_file -- ${all_opts[@]}" + echo $compiler "$final_in_file" $all_flags + fi + + ###### print source file (if the compiler doesn't do it automatically) #### + if [ "$manually_print_target" == "1" ]; then + echo "$file_base" + fi + + ###### compile ############################################################ $compiler "$final_in_file" $all_flags } @@ -326,23 +329,28 @@ function bld_link { fi out_file="$out_name$dot_ext_out" + ###### move to output folder ############################################## + mkdir -p "$build_path" + cd $build_path + ###### diagnostic output ################################################## local final_in_files="${interm_obj[@]} ${in_obj[@]} ${in_lib[@]}" if [ "$diagnostics" == "1" ]; then echo "lnk $final_in_files -- ${all_opts[@]}" fi - ###### print output file ################################################## - echo "$out_file" - - ###### move to output folder ############################################## - mkdir -p "$build_path" - cd $build_path - ###### link ############################################################### if [ "$linker_kind" == "link" ]; then + if [ "$diagnostics" == "1" ]; then + echo $linker -OUT:"$out_file" $flags $final_in_files + fi + echo "$out_file" $linker -OUT:"$out_file" $flags $final_in_files elif [ "$linker_kind" == "clang" ]; then + if [ "$diagnostics" == "1" ]; then + echo $linker -o "$out_file" $flags $final_in_files + fi + echo "$out_file" $linker -o "$out_file" $flags $final_in_files else echo "ERROR: invokation not defined for this linker" @@ -570,9 +578,9 @@ implicit_opts=($out_name $compiler $linker $compile_mode $os $arch $ctx) ###### Object File Extension ################################################## -dot_ext_obj=".obj" -if [[ "$linker" == "clang" || "$linker" == "gcc" ]]; then - dot_ext_obj=".o" +dot_ext_obj=".o" +if [[ "$compiler" == "cl" ]]; then + dot_ext_obj=".obj" fi diff --git a/bin/build_tests.sh b/bin/build_tests.sh index 83ddb2a..8dbe1ba 100644 --- a/bin/build_tests.sh +++ b/bin/build_tests.sh @@ -9,7 +9,7 @@ cd .. echo "~~~ Build All Tests ~~~" bin/bld_core.sh show_ctx -bin/bld_core.sh unit sanity_test tests/sanity_tests.c +bin/bld_core.sh unit sanity_tests tests/sanity_tests.c bin/bld_core.sh unit unicode_test tests/unicode_test.c bin/bld_core.sh unit cpp_build_test tests/cpp_build_test.cpp diff --git a/bin/linker_flags.txt b/bin/linker_flags.txt index 9b96278..5b3f156 100644 --- a/bin/linker_flags.txt +++ b/bin/linker_flags.txt @@ -1 +1,7 @@ -###### TODO ################################################################### \ No newline at end of file +###### link ################################################################### +lld-link>-nologo +lld-link>-DEFAULTLIB:libcmt +lld-link>-OPT:REF +lld-link>-INCREMENTAL:NO +lld-link>debug>-DEBUG +lld-link>dll>-DLL diff --git a/source/md.c b/source/md.c index 78dfd4e..4a65442 100644 --- a/source/md.c +++ b/source/md.c @@ -301,7 +301,7 @@ MD_StaticAssert(sizeof(MD_ArenaDefault) <= MD_IMPL_ArenaHeaderSize, arena_def_si static MD_Arena* MD_ArenaDefaultAlloc(MD_u64 cap){ void *mem = MD_IMPL_Reserve(cap); - MD_u64 cmt = MD_ClampBot(MD_ArenaDefault_CommitSize, cap); + MD_u64 cmt = MD_ClampTop(cap, MD_ArenaDefault_CommitSize); MD_IMPL_Commit(mem, cmt); MD_ArenaDefault *arena = (MD_ArenaDefault*)mem;