Asterisk 16.28.0 introduced a new module: res_geolocation (and also a corresponding res_pjsip_geolocation). Building this module fails, and the failure is connected to some newly-added rules to asterisk/Makefile.rules that are supposed to generate .o files from XML or XSLT source files using just cc/ld (lines 207-220). A sample invocation with a trivial foo.xml that includes the expanded ld invocation is: $ cc -g -nostartfiles -nodefaultlibs -nostdlib -r -Wl,-b,binary -o foo.o foo.xml ld: error: target emulation unknown: -m or at least one .o file required cc: error: linker command failed with exit code 1 (use -v to see invocation) $ cc -v -g -nostartfiles -nodefaultlibs -nostdlib -r -Wl,-b,binary -o foo.o foo.xml FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303) Target: x86_64-unknown-freebsd13.1 Thread model: posix InstalledDir: /usr/bin "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o foo.o -L/usr/lib -r -r -b binary foo.xml ld: error: target emulation unknown: -m or at least one .o file required cc: error: linker command failed with exit code 1 (use -v to see invocation) $ I have attempted the build in two different manners on this system: poudriere and portmaster, both with the same options file. The poudriere build completes, but it does not attempt to build res_geolocation. The portmaster build fails on turning the res_geolocation XML files into objects. I have not yet found the difference in the environments that caused the difference in whether or not builds of res_geolocation are attempted. Build output specifically of res_geolocation: cc -o res_geolocation.o -c res_geolocation.c -MD -MT res_geolocation.o -MF .res_geolocation.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality cc -o res_geolocation/geoloc_civicaddr.o -c res_geolocation/geoloc_civicaddr.c -MD -MT res_geolocation/geoloc_civicaddr.o -MF .res_geolocation_geoloc_civicaddr.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality cc -o res_geolocation/geoloc_common.o -c res_geolocation/geoloc_common.c -MD -MT res_geolocation/geoloc_common.o -MF .res_geolocation_geoloc_common.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality cc -o res_geolocation/geoloc_config.o -c res_geolocation/geoloc_config.c -MD -MT res_geolocation/geoloc_config.o -MF .res_geolocation_geoloc_config.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality res_geolocation/geoloc_config.c:600:81: warning: expression which evaluates to zero treated as a null pointer constant of type 'const char *' [-Wnon-literal-null-conversion] ast_sorcery_object_field_register_custom(geoloc_sorcery, "location", "format", AST_GEOLOC_FORMAT_NONE, ^~~~~~~~~~~~~~~~~~~~~~ /usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include/asterisk/sorcery.h:1006:62: note: expanded from macro 'ast_sorcery_object_field_register_custom' __ast_sorcery_object_field_register(sorcery, type, name, default_val, OPT_CUSTOM_T, config_handler, sorcery_handler, multiple_handler, flags, 0, 0, VA_NARGS(__VA_ARGS__), __VA_ARGS__); ^~~~~~~~~~~ 1 warning generated. cc -o res_geolocation/geoloc_datastore.o -c res_geolocation/geoloc_datastore.c -MD -MT res_geolocation/geoloc_datastore.o -MF .res_geolocation_geoloc_datastore.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality cc -o res_geolocation/geoloc_dialplan.o -c res_geolocation/geoloc_dialplan.c -MD -MT res_geolocation/geoloc_dialplan.o -MF .res_geolocation_geoloc_dialplan.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality cc -o res_geolocation/geoloc_eprofile.o -c res_geolocation/geoloc_eprofile.c -MD -MT res_geolocation/geoloc_eprofile.o -MF .res_geolocation_geoloc_eprofile.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality cc -o res_geolocation/geoloc_gml.o -c res_geolocation/geoloc_gml.c -MD -MT res_geolocation/geoloc_gml.o -MF .res_geolocation_geoloc_gml.o.d -MP -pthread -I/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/include -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -I/usr/local/include/libxml2 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fblocks -isystem /usr/local/include -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC -DAST_MODULE=\"res_geolocation\" -DAST_MODULE_SELF_SYM=__internal_res_geolocation_self -I/usr/local/include/libxml2 -I/usr/local/include/libxml2 -O2 -pipe -I/usr/local/include/lua52 -DLIBICONV_PLUG -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -Wno-unused-value -Wno-parentheses-equality cc -g -nostartfiles -nodefaultlibs -nostdlib -r -Wl,-b,binary -o res_geolocation/pidf_lo_test.o res_geolocation/pidf_lo_test.xml ld: error: target emulation unknown: -m or at least one .o file required cc: error: linker command failed with exit code 1 (use -v to see invocation) gmake[2]: *** [/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/Makefile.rules:216: res_geolocation/pidf_lo_test.o] Error 1 gmake[2]: Leaving directory '/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0/res' gmake[1]: *** [Makefile:396: res] Error 2 gmake[1]: Leaving directory '/usr/obj/usr/ports/net/asterisk16/work/asterisk-16.28.0' *** Error code 1 Stop. make: stopped in /usr/ports/net/asterisk16 ===>>> make build failed for net/asterisk16
Hi, Thanks for reporting this. I did not notice such detail when upgrading. It looks like this is using an obscure feature of at least some compilers. Obscure because in half an hour of googling I have failed to find any description of such functionality for any compiler. My suspect is that this is a gcc specific feature and maybe clang can't do it natively. Anyway I'm still looking. It will require a new OPTION in the port to work for sure, especially if extra tools are required to make this work. Could take some time.
Created attachment 236182 [details] patch v1 HI, I found how to make this work I think. I compiled it successfully in poudriere I'm attaching a patch, can you test it and report back? Thanks!
This patch does apply to asterisk16 with only minor fuzz. I have successfully built asterisk16 using poudriere with the combinations of options: unset PJSIP no GEOLOCATION, unset PJSIP and set GEOLOCATION, set PJSIP and set GEOLOCATION. In the case when GEOLOCATION is not explicitly set in the options file, res_geolocation is not built. When GEOLOCATION is set, res_geolocation is built. When I tried building asterisk16 with the patch applied using the portmaster environment, with GEOLOCATION either not present or unset in the options file (but libxslt installed), the build still tries to include res_geolocation and fails, with a different error this time: cc -g -nostartfiles -nodefaultlibs -nostdlib -z noexecstack -r -Wl,-b,binary,-m,%%LLD_EMULATION%% -o res_geolocation/pidf_lo_test.o res_geolocation/pidf_lo_test.xml ld: error: unknown emulation: %%LLD_EMULATION%% cc: error: linker command failed with exit code 1 (use -v to see invocation) When GEOLOCATION is set in the options file, that line expansion matches that of the poudriere GEOLOCATION builds, and the build succeeds: cc -g -nostartfiles -nodefaultlibs -nostdlib -z noexecstack -r -Wl,-b,binary,-m,elf_x86_64 -o res_geolocation/pidf_lo_test.o res_geolocation/pidf_lo_test.xml
(In reply to Seneca Cunningham from comment #3) Thanks for testing. First of all please note that this patch is against asterisk 1.8. If it works with 1.6 it is by pure chance. I need to look at 1.6 still. When using poudriere a clean environment is warranted, and the res_geolocation module is enabled ONLY if the option is selected. Using portmaster I guess there is no warranty of leftovers. Are you sure "make clean" was ran in the port before testing? Could you try again making sure make clean is run (that is, no "work" directory)? Changing options and running make without "make clean" before it is prone to breaking for any port. Asterisk especially can leave behind data from the previous menuselect run, with features enabled. The error you're seeing happens because some text in the Makefile is only replaced with the correct content if the option is selected, so the error you're seeing is expected. Anyway I see you confirm the patch behaves as expected, I'll clean it up a little in the while.
I still run Asterisk 16, not Asterisk 18 (and Asterisk 1.6 and 1.8 are from 2008 and 2010, respectively). I noticed this issue when I tried building Asterisk 16. What leftovers? The portmaster test with GEOLOCATION set was the last test build. Asterisk's build is picking up on the copy of libxslt that is installed because other installed ports depend upon it. I did it in the sequence of no GEOLOCATION, unset GEOLOCATION, then finally, set GEOLOCATION. Portmaster does not isolate the build environment from the running system as poudriere does. After explicitly running "make clean" on the port, even though portmaster runs "make clean" before attempting a build by default, the unset and no GEOLOCATION builds still see the installed copy of libxslt and fail when building res_geolocation. The build with GEOLOCATION set still succeeds.
(In reply to Seneca Cunningham from comment #5) I did not notice you were using asterisk 16, anyway I'll attach a new patch shortly for both asterisk16 and asterisk18. The patches are functionally the same. Sorry for my lapsus for 1.6 vs 16. No need to be so fussy about this. The "leftovers" I was talking about are the menuselect configuration files, which survive in work, and can "remember" settings from a previous build. I'm taliing of the files in the work directory. I'm not sure why in your case the res_geolocation build is tried also with the option off. That should not be the case. The presence of libxslt should not be enough AFAIK(this can be verified by removing libxslt and checking if the res_geolocation option stays off) are you sure it's the presence of that to trigger res_geolocation? I can force it off when the option is off, but this has never been necessary with other options, so I'd like to understand what is happening here. Could you attach a log of the full build so I can try to get an idea of what is happening?
Created attachment 236230 [details] patch v2 Adding patch for both versions of asterisk.
Created attachment 236231 [details] patch v3 I was able to reproduce the issue. Looks like asterisk tries really had to enable the geolocation module. So I've added directives to forcibly disable it when the option is off. This should fix the issue when building outside of poudriere.
Worked as intended in my non-poudriere environment.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=e32f5ab610e49d510e70a9e5d8851a8b436fc18c commit e32f5ab610e49d510e70a9e5d8851a8b436fc18c Author: Guido Falsi <madpilot@FreeBSD.org> AuthorDate: 2022-08-30 08:06:58 +0000 Commit: Guido Falsi <madpilot@FreeBSD.org> CommitDate: 2022-08-30 08:06:58 +0000 net/asterisk18: Add red_geolocation support Add a GEOLOCATION option (off by default) to allow building the new res_geolocation module, which allows to use geolocation information in SIP protocol (upstream provider support required). Since it requires architecture specific flags to be passed to ld, I've enabled it only for tier 1 architectures at present. PR: 266053 Tested by: Seneca Cunningham <seneca@vybenetworks.com> net/asterisk18/Makefile | 28 +++++++++++++++++++++++-- net/asterisk18/files/patch-Makefile.rules (new) | 27 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=103c97c2f57a0b959c68f69650dc98648f2dd908 commit 103c97c2f57a0b959c68f69650dc98648f2dd908 Author: Guido Falsi <madpilot@FreeBSD.org> AuthorDate: 2022-08-30 08:06:02 +0000 Commit: Guido Falsi <madpilot@FreeBSD.org> CommitDate: 2022-08-30 08:06:02 +0000 net/asterisk16: Add red_geolocation support Add a GEOLOCATION option (off by default) to allow building the new res_geolocation module, which allows to use geolocation information in SIP protocol (upstream provider support required). Since it requires architecture specific flags to be passed to ld, I've enabled it only for tier 1 architectures at present. PR: 266053 Tested by: Seneca Cunningham <seneca@vybenetworks.com> net/asterisk16/Makefile | 28 +++++++++++++++++++++++-- net/asterisk16/files/patch-Makefile.rules (new) | 27 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-)
Patch committed. Thanks for reporting and testing!