diff --git a/README.markdown b/README.markdown index e17b218..1928027 100644 --- a/README.markdown +++ b/README.markdown @@ -432,9 +432,21 @@ The following Unix compiler cc/gcc options are understood by cccl: - **-pedantic** Removed/ignored, cl.exe does not support any equivalent - **-std=_standard_** Converts to cl.exe' **/std:_standard_** for **c++14**, **gnu++14**, **c11**, **gnu11** and later **standard**, otherwise removed/ignored - **-Wl,(,)** Options are passed to the linker + - **--dynamicbase** Converts to link.exe's **/DYNAMICBASE** + - **--disable-dynamicbase** Converts to link.exe's **/DYNAMICBASE:NO** + - **--gc-sections** Converts to link.exe's **/OPT:REF** + - **--icf** Converts to link.exe's **/OPT:ICF** + - **--nxcompat** Converts to link.exe's **/NXCOMPAT** + - **--disable-nxcompat** Converts to link.exe's **/NXCOMPAT:NO** + - **--high-entropy-va** Converts to link.exe's **/HIGHENTROPYVA** + - **--disable-high-entropy-va** Converts to link.exe's **/HIGHENTROPYVA:NO** + - **--out-implib** Converts to link.exe's **/IMPLIB** - **-Werror** Converts to cl.exe's **/WX** - **-W** Remaining warnings removed/ignored, please provide **/W** options for warning control - **-fno-strict-aliasing** Removed/ignored + - **-flto** Converted to **/GL** + - **-fdata-sections** Converted to **/Gw** + - **-ffunction-sections** Converted to **/Gy** - **-isystem** Converted to **/I** - **-include** Converted to **/FI** - **-MT** Due to conflict with cl.exe's **/MT** option, there is no support and cccl exits diff --git a/cccl b/cccl index e977449..03a3a27 100755 --- a/cccl +++ b/cccl @@ -101,7 +101,65 @@ for arg in $@; do esac done -processargs() +process_link_opts() +{ + shift # -Wl + while true; do + case $1 in + --) + break; + ;; + + --dynamicbase) + linkopt+=("${slash}DYNAMICBASE") + ;; + + --disable-dynamicbase) + linkopt+=("${slash}DYNAMICBASE:NO") + ;; + + --gc-sections) + linkopt+=("${slash}OPT:REF") + ;; + + --icf) + linkopt+=("${slash}OPT:ICF") + ;; + + --nxcompat) + linkopt+=("${slash}NXCOMPAT") + ;; + + --disable-nxcompat) + linkopt+=("${slash}NXCOMPAT:NO") + ;; + + --high-entropy-va) + linkopt+=("${slash}HIGHENTROPYVA") + ;; + + --disable-high-entropy-va) + linkopt+=("${slash}HIGHENTROPYVA:NO") + ;; + + --out-implib) + shift + linkopt+=("${slash}IMPLIB:$1") + ;; + + -Bshareable | -shared | --dll) + linkopt+=("${slash}DLL") + ;; + + *) + linkopt+=("$1") + ;; + esac + shift + done +} + +process_opts() { ### Run through every option and convert it to the proper MS one while test $# -gt 0; do @@ -293,10 +351,8 @@ EOF ;; -Wl,*) - IFS=',' read -ra linkopt2 <<< "$(echo $1 | sed 's/-Wl,//')" - for linkarg in ${linkopt2[@]}; do - linkopt+=("${linkarg}") - done + IFS=',' read -ra linkopt2 <<< "$1" + process_link_opts "${linkopt2[@]}" -- ;; -Werror) @@ -306,8 +362,24 @@ EOF #ignore remaining warnings ;; - -fno-strict-aliasing*) - #ignore aliasing + -f*) + case $1 in + -fno-strict-aliasing*) + #ignore aliasing + ;; + + -flto | -flto=*) + clopt+=("${slash}GL") + ;; + + -fdata-sections) + clopt+=("${slash}Gw") + ;; + + -ffunction-sections) + clopt+=("${slash}Gy") + ;; + esac ;; -isystem) @@ -394,9 +466,7 @@ done # Whitespace in paths is dealt with by setting IFS and using bash arrays # Except additional arguments in CCCL_OPTIONS need to be space separated -processargs $CCCL_OPTIONS -IFS="" -processargs $@ +process_opts ${CCCL_OPTIONS[@]} $@ if test $shared_index -ge 0 -a -n "$debug"; then clopt[$shared_index]="${slash}LDd"