Skip to content

Commit

Permalink
fixes for fpic and wrapper disable
Browse files Browse the repository at this point in the history
  • Loading branch information
ahueck committed Jun 30, 2021
1 parent 4621e97 commit eab5701
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions scripts/typeart-wrapper.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ function global_init() {
}

function is_wrapper_disabled() {
if [ -n "${TYPEART_WRAPPER}" ] ; then
return 0
fi

case "${TYPEART_WRAPPER}" in
off|OFF|0|false|FALSE)
return 1
Expand Down Expand Up @@ -119,6 +115,7 @@ function parse_cmd_line() {
found_src_file=0
found_obj_file=0
found_exe_file=0
found_fpic=0
skip_typeart=0
typeart_to_asm=0
while (( "$#" )); do
Expand Down Expand Up @@ -163,6 +160,12 @@ function parse_cmd_line() {
shift
fi
;;
-fPIC)
# llc requires special flag
found_fpic=1
ta_more_args="$ta_more_args $1"
shift
;;
*) # preserve other arguments
ta_more_args="$ta_more_args $1"
shift
Expand Down Expand Up @@ -192,21 +195,27 @@ function main_compile() {
fi

local out_file="${object_file}"
local llc_flag_file="-filetype=obj"
local llc_flags="--filetype=obj"

if [ "$typeart_to_asm" == 1 ] ; then
local llc_flag_file="-filetype=asm"
local llc_flags="--filetype=asm"
local out_file="${asm_file}"
fi

if [ "$found_fpic" == 1 ] ; then
local llc_flags="$llc_flags --relocation-model=pic"
fi

$compiler ${ta_more_args} ${typeart_includes} -O1 -Xclang -disable-llvm-passes -S -emit-llvm "${source_file}" -o - |
$opt_tool ${typeart_plugin} ${typeart_heap_mode_args} |
$opt_tool ${optimize} -S |
$opt_tool ${typeart_plugin} ${typeart_stack_mode_args} |
$llc_tool -x=ir ${llc_flag_file} -o "${out_file}"
$llc_tool -x=ir ${llc_flags} -o "${out_file}"
}

function main_in() {
global_init

is_wrapper_disabled
typeart_disabled=$?
skip_typeart_compile "$@"
Expand All @@ -215,8 +224,6 @@ function main_in() {
return 0
fi


global_init
is_linking "$@"
if [ "$?" == 1 ] ; then
main_link "$@"
Expand Down

0 comments on commit eab5701

Please sign in to comment.