Ticket #9948: cflags-check-linking.patch

File cflags-check-linking.patch, 1.8 KB (added by sqrt2, 6 years ago)

Implement optional linking check in TOR_CHECK_CFLAGS, handle stack protection issues (corrected version)

  • acinclude.m4

    diff -U2 tor-0.2.4.17-rc/acinclude.m4 tor-0.2.4.17-rc-new/acinclude.m4
    old new  
    4444
    4545dnl 1:flags
     46dnl 2:also try to link (yes: non-empty string)
     47dnl   will set yes or no in $tor_can_link_$1 (as modified by AS_VAR_PUSHDEF)
    4648AC_DEFUN([TOR_CHECK_CFLAGS], [
    4749  AS_VAR_PUSHDEF([VAR],[tor_cv_cflags_$1])
     
    5254                   [AS_VAR_SET(VAR,yes)],
    5355                   [AS_VAR_SET(VAR,no)])
     56    if test x$2 != x; then
     57      AS_VAR_PUSHDEF([can_link],[tor_can_link_$1])
     58      AC_TRY_LINK([], [return 0;],
     59                  [AS_VAR_SET(can_link,yes)],
     60                  [AS_VAR_SET(can_link,no)])
     61      AS_VAR_POPDEF([can_link])
     62    fi
    5463    CFLAGS="$tor_saved_CFLAGS"
    5564  ])
  • configure.ac

    diff -U2 tor-0.2.4.17-rc/configure.ac tor-0.2.4.17-rc-new/configure.ac
    old new  
    570570        TOR_CHECK_CFLAGS(-Qunused-arguments)
    571571    fi
    572     TOR_CHECK_CFLAGS(-fstack-protector-all)
     572    TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
     573    AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
     574    AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
     575    AS_VAR_IF(can_compile, [yes],
     576        AS_VAR_IF(can_link, [yes],
     577                  [],
     578                  AC_MSG_ERROR([We tried to build with stack protection; your compiler supports it but your libc does not provide it. Install libssp or --disable-gcc-hardening.]))
     579        )
     580    AS_VAR_POPDEF([can_link])
     581    AS_VAR_POPDEF([can_compile])
    573582    TOR_CHECK_CFLAGS(-Wstack-protector)
    574583    TOR_CHECK_CFLAGS(-fwrapv)