diff options
author | midipix <writeonce@midipix.org> | 2024-02-18 06:33:00 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-02-18 07:49:54 +0000 |
commit | 9c9786ff4c74aa5b786e3a0fc58d8a62e12e6450 (patch) | |
tree | 2483255da560d4a92fc2b2154dacf149992f2825 /sofort/cfgtest | |
parent | 2bf6f8a490b10de373efb39d673968814f192741 (diff) | |
download | perk-9c9786ff4c74aa5b786e3a0fc58d8a62e12e6450.tar.bz2 perk-9c9786ff4c74aa5b786e3a0fc58d8a62e12e6450.tar.xz |
build system: ccenv: detect compiler support of visibility attributes.
Diffstat (limited to 'sofort/cfgtest')
-rw-r--r-- | sofort/cfgtest/cfgtest.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sofort/cfgtest/cfgtest.sh b/sofort/cfgtest/cfgtest.sh index debdb8c..6abbfea 100644 --- a/sofort/cfgtest/cfgtest.sh +++ b/sofort/cfgtest/cfgtest.sh @@ -15,6 +15,7 @@ # mb_cfgtest_cfgtype: the type of the current test (host/native) # mb_cfgtest_makevar: the make variable affected by the current test # mb_cfgtest_headers: headers for ad-hoc inclusion with the current test +# mb_cfgtest_attr: if supported, the compiler-specific attribute definition cfgtest_newline() @@ -131,6 +132,15 @@ cfgtest_epilog() return 1 fi + if [ "${1}" = 'attr' ] && [ "${2}" = '(error)' ]; then + printf '\n\ncfgtest: the %s compiler %s %s_ attribute.\n' \ + "$mb_cfgtest_cfgtype" \ + 'does not appear to support the _' \ + "${3}" >&3 + printf '%s\n' '------------------------' >&3 + return 1 + fi + if [ "${2}" = '-----' ] || [ "${2}" = '(missing)' ]; then printf '\n\ncfgtest: %s %s is missing or cannot be found.\n' "${1}" "${3}" >&3 printf '%s\n' '------------------------' >&3 @@ -246,6 +256,8 @@ cfgtest_common_init() fi elif [ "$cfgtest_type" = 'asm' ]; then cfgtest_fmt='%s -c -xc - -o a.out' + elif [ "$cfgtest_type" = 'attr' ]; then + cfgtest_fmt='%s -c -xc - -o a.out -Werror' elif [ "$cfgtest_type" = 'lib' ]; then cfgtest_fmt='%s -xc - -o a.out' elif [ "$cfgtest_type" = 'ldflag' ]; then @@ -534,6 +546,39 @@ cfgtest_type_size() } +cfgtest_attr_visibility() +{ + # init + cfgtest_prolog 'compiler visibility attr' "${1}" + + cfgtest_attr_syntax='__attribute__((__visibility__("'"${1}"'")))' + cfgtest_code_snippet="$cfgtest_attr_syntax"' int f_'"${1}"'(void);' + + cfgtest_common_init 'attr' + + # execute + cfgtest_ret=1 + + printf '%s' "$cfgtest_src" \ + | eval $(printf '%s' "$cfgtest_cmd") \ + > /dev/null 2>&3 \ + || cfgtest_epilog 'attr' '(error)' "${1}" \ + || return + + # result + mb_cfgtest_attr=$(printf '__attribute__\\(\\(__visibility__\\(\\"%s\\"\\)\\)\\)' "${1}") + + cfgtest_ret=0 + + printf 'cfgtest: %s compiler: above attribute is supported; see also ccenv/%s.mk.\n\n' \ + "$mb_cfgtest_cfgtype" "$mb_cfgtest_cfgtype" >&3 + + cfgtest_epilog 'attr' '(ok)' + + return 0 +} + + cfgtest_code_snippet_asm() { # init |