From: Thomas Klausner <thomasklausner%users.sourceforge.net@localhost> Subject: Re: CVS commit: wip/n2n Date: Tue, 1 Apr 2014 11:01:11 +0200 > On Fri, Mar 28, 2014 at 07:44:23PM +0000, PHO / phonohawk wrote: >> Module name: wip >> Committed by: phonohawk >> Date: Fri Mar 28 19:44:08 UTC 2014 >> >> Modified Files: >> wip/n2n: TODO >> >> Log Message: >> TODO: Remove Linux from the list of untested platforms. It worked very well. > > I've tried compiling on NetBSD/amd64/6.99.39/clang, but it failed > linking: > > libn2n.a(tuntap_netbsd.c.o): In function `tuntap_open': > /scratch/wip/n2n/work/n2n/n2n_v2/tuntap_netbsd.c:(.text+0x328): undefined > reference to `tun_close' > clang: error: linker command failed with exit code 1 (use -v to see > invocation) > > Can you please take a look? Whoa! I just found why it worked for me and was really surprised. Will fix it soon. Here's an explanation. tuntap_{freebsd,netbsd,osx}.c all have the same mistake: > void tun_close(tuntap_dev *device); ... > FILE *fd; ... > fd = popen(buf, "r"); > if(fd < 0) { > tun_close(device); > return(-1); > } else { tun_close() is indeed undefined, and the correct function to call is tuntap_close(). The weirdest part is that since the conditional "fd < 0" never holds, GCC silently removes the "then" part so the linker never sees any references to tun_close(). GCC is still happy because there is a prototype declaration even if it's bogus. This is logical but I haven't thought of this kind of problem. Clang, on the other hand, does not do this optimization so the linker fails. _______________________________________________________ - PHO - http://cielonegro.org/ OpenPGP public key: 1024D/1A86EF72 Fpr: 5F3E 5B5F 535C CE27 8254 4D1A 14E7 9CA7 1A86 EF72
Attachment:
pgphB4hPt2jWS.pgp
Description: PGP signature
------------------------------------------------------------------------------
_______________________________________________ pkgsrc-wip-discuss mailing list pkgsrc-wip-discuss%lists.sourceforge.net@localhost https://lists.sourceforge.net/lists/listinfo/pkgsrc-wip-discuss