Re: CVS commit: wip/n2n

PHO <[email protected]> Fri, 04 Apr 2014 21:57:09 +0900 (JST)
Newsgroups gmane.os.netbsd.devel.pkgsrc.wip.general
Message-ID <[email protected]>
--===============1025331945998855893==
Content-Type: Multipart/Signed; protocol="application/pgp-signature";
	micalg=pgp-sha1;
	boundary="--Security_Multipart(Fri_Apr__4_21_57_09_2014_588)--"
Content-Transfer-Encoding: 7bit

----Security_Multipart(Fri_Apr__4_21_57_09_2014_588)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

From: Thomas Klausner <[email protected]>
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

----Security_Multipart(Fri_Apr__4_21_57_09_2014_588)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)

iD8DBQBTPqwlFOecpxqG73IRAganAKCQ5eesNtGpLU4HcXHcTMhOd92nzACfbEMF
nStBh7wOE9xr/JXeFwiPC0U=
=ApPY
-----END PGP SIGNATURE-----

----Security_Multipart(Fri_Apr__4_21_57_09_2014_588)----


--===============1025331945998855893==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------

--===============1025331945998855893==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
pkgsrc-wip-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pkgsrc-wip-discuss

--===============1025331945998855893==--