@@ -117,10 +117,13 @@ if test ! "$output" -ot "$src"; then return fi fi - $m4 $macro_compile_env -I "$gen" $flags "$src" > "$output" - announce $m4 $macro_compile_env -I "$gen" $flags "$src" \> "$output" + if test "$debug" = yes; then + local dflag=-Dcompile_debug=yes + fi + $m4 $macro_compile_env $dflag -I "$gen" $flags "$src" > "$output" + announce $m4 $macro_compile_env $dflag -I "$gen" $flags "$src" \> "$output" # yes, this is incredibly stupid. if you know a better way, feel # free to submit a fix. the problem is there's no way to pass > # to report in such a way that it'll do the right thing, and if # you just write > it redirects *report's* output, instead of @@ -135,9 +138,12 @@ if test ! "$output" -ot "$src"; then return fi fi - report $asm $flags "-f$bin_fmt" -i "$gen" "$src" -o "$output"; + if test "$debug" = yes; then + local dflag="-g dwarf2" + fi + report $asm $flags $dflag "-f$bin_fmt" -i "$gen" "$src" -o "$output"; } comp_co() { comp_c $1 $2 "-c -fPIC"; } comp_c(){ local src=$1 @@ -148,9 +154,14 @@ return fi fi # only rebuild the file if the source file is newer - report $cc $src $3 -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -nostdlib "-L$to" "-o$output" + if test "$debug" = yes; then + local dflag="-g" + else + local dflag="-O4" + fi + report $cc $src $3 $dflag -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -ffreestanding -nostdlib "-L$to" "-o$output" } say "commencing libk build $build at $(timestamp)" # set -x