asterisk-16.x: add Asterisk 16 411/head
authorSebastian Kemper <sebastian_ml@gmx.net>
Sat, 27 Apr 2019 14:04:34 +0000 (16:04 +0200)
committerSebastian Kemper <sebastian_ml@gmx.net>
Wed, 1 May 2019 09:29:49 +0000 (11:29 +0200)
commit6cdf80bd46e1d79f5bbb33aa00954f7688953769
tree452b0d80a6a0f9f469bac42d051056a1712305a8
parent9a8f3b372610bb9dc2bdbe58328f72125b15d200
asterisk-16.x: add Asterisk 16

Initial commit of Asterisk 16. Cleans up Makefile; the version number
now only occurs once in it.

Upstream removed the following modules:

  - format_jpeg
  - res_pjsip_registrar_expire (functionality was moved into
    res_pjsip_registrar.)

pjsip has a new dependency, res-http-websocket.

Notes:

  - replaced res_ninit patch

    Replaced patch with the one from Alpine. It's a bit more flexible and
    allows usage of res_ninit where available (when building against
    glibc).

  - fixed musl compiles

    astmm.h now always gets included by asterisk.h, redefining allocators.
    This causes breakage on musl:

    ccache_cc -o chan_pjsip.o -c chan_pjsip.c -MD -MT chan_pjsip.o -MF .chan_pjsip.o.d -MP -pthread -I/home/sk/tmp/openwrt/build_dir/target-mips_24kc_musl/asterisk-16.2.1/include -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -mips16 -minterlink-mips16 -iremap/home/sk/tmp/openwrt/build_dir/target-mips_24kc_musl/asterisk-16.2.1:asterisk-16.2.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libiconv-stub/include -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libintl-stub/include -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/include -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/include -I/home/sk/tmp/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/usr/include -I/home/sk/tmp/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/include/fortify -I/home/sk/tmp/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/include -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libiconv-stub/include -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libintl-stub/include    -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/include/libxml2  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations       -fPIC -DAST_MODULE=\"chan_pjsip\" -DAST_MODULE_SELF_SYM=__internal_chan_pjsip_self  -DPJ_AUTOCONF=1 -DPJ_IS_BIG_ENDIAN=1 -DPJ_IS_LITTLE_ENDIAN=0 -fPIC -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/include
    In file included from /home/sk/tmp/openwrt/build_dir/target-mips_24kc_musl/asterisk-16.2.1/include/asterisk.h:23:0,
                     from chan_pjsip.c:35:
    /home/sk/tmp/openwrt/build_dir/target-mips_24kc_musl/asterisk-16.2.1/include/asterisk/astmm.h:158:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
      Do_not_use_calloc__use_ast_calloc->fail(a, b)
                                       ^
    /home/sk/tmp/openwrt/build_dir/target-mips_24kc_musl/asterisk-16.2.1/include/asterisk/astmm.h:162:77: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
      Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a)
                                                                                 ^
    make[4]: *** [/home/sk/tmp/openwrt/build_dir/target-mips_24kc_musl/asterisk-16.2.1/Makefile.rules:153: chan_pjsip.o] Error 1

    The problem is that with _GNU_SOURCE defined musl also declares calloc in
    <sched.h> - and when asterisk's source includes <sched.h> _after_
    "asterisk/astmm.h" the definition clashes with the macro. Timo Teräs from
    Alpine Linux fixed this by including <pthread.h> in "asterisk/compat.h". He
    chose to include <pthread.h> instead of <sched.h> because the original
    header inclusion chain seems to be "asterisk/astobj2.h" ->
    "asterisk/lock.h" -> <pthread.h> -> <sched.h>. It seems Asterisk
    practically never includes <sched.h> directly.

  - added loader workaround for musl

    When the modules are loaded, asterisk segfaults on musl.

       Asterisk Dynamic Loader Starting:
      [Mar  2 22:30:05] NOTICE[20712]: loader.c:2230 load_modules: 91 modules will be loaded.
      Segmentation fault

      [48817.544248] do_page_fault(): sending SIGSEGV to asterisk for invalid read access from 00000000
      [48817.544258] epc = 77f6b764 in libc.so[77ef8000+94000]
      [48817.544285] ra  = 0048d579 in asterisk[400000+160000]

    The real problem is that the loader expects dlopen to always run the
    constructor, which doesn't happen with musl, because its dlopen is
    permanent.

    This commit adds a new configure switch '--enable-permanent-dlopen'.
    When enabled, the loader will manually call 'ast_module_register(...)'
    and 'ast_module_unregister(...)' when needed.

  - allow eventfd detection

    Asterisk 16 wants to use eventfd, but it doesn't allow the detection
    during cross-compiling. This results in runtime warnings, for instance
    when shutting down:

      [Mar  2 22:37:41] WARNING[21593]: alertpipe.c:112 ast_alertpipe_read: read() failed: Bad file descriptor
      [Mar  2 22:37:41] WARNING[21593]: alertpipe.c:112 ast_alertpipe_read: read() failed: Bad file descriptor
      [Mar  2 22:37:41] WARNING[21593]: alertpipe.c:112 ast_alertpipe_read: read() failed: Bad file descriptor

    Relax the configure script so that eventfd can also be detected when
    cross-compiling.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
12 files changed:
net/asterisk-16.x/Makefile [new file with mode: 0644]
net/asterisk-16.x/files/asterisk.default [new file with mode: 0644]
net/asterisk-16.x/files/asterisk.init [new file with mode: 0644]
net/asterisk-16.x/patches/001-disable-semaphores-check.patch [new file with mode: 0644]
net/asterisk-16.x/patches/002-configure-fix-detection-of-re-entrant-resolver-funct.patch [new file with mode: 0644]
net/asterisk-16.x/patches/030-GNU-GLOB-exts-only-on-glibc.patch [new file with mode: 0644]
net/asterisk-16.x/patches/053-musl-mutex-init.patch [new file with mode: 0644]
net/asterisk-16.x/patches/056-fix-check_expr2-build.patch [new file with mode: 0644]
net/asterisk-16.x/patches/100-build-reproducibly.patch [new file with mode: 0644]
net/asterisk-16.x/patches/110-fix-astmm.patch [new file with mode: 0644]
net/asterisk-16.x/patches/120-loader.patch [new file with mode: 0644]
net/asterisk-16.x/patches/130-eventfd.patch [new file with mode: 0644]