freebsd support

120 views
Skip to first unread message

d...@rabson.org

unread,
Aug 2, 2015, 6:59:33 AM8/2/15
to bazel-discuss
I spent a little time today looking at porting bazel to FreeBSD. For the most part, this is straightforward and I have everything compiling. There is a problem though - bazel needs to be able to get the process ID of the server given an AF_LOCAL socket connected to the server. Unfortunately, there is no way of getting this on FreeBSD - the only peer information available is its creds (uid, gid etc.)

Any ideas on how to get past this? I could easily add kernel support in FreeBSD along the lines of Mac OS X's LOCAL_PEERPID socket option but that would limit bazel support to very recent versions of FreeBSD since I don't really have the time to support back-porting such a feature to older versions of FreeBSD. In my opinion, simply asking the server for its PID or adding a sever.pid file next to the server.socket would be a lot more portable.

Doug Rabson

unread,
Aug 4, 2015, 2:49:56 AM8/4/15
to bazel-discuss
At this point, I have a functioning port which self-hosts on FreeBSD-current and is likely to work on FreeBSD-10 and possibly -9 as well although I haven't tested that. The approach I took for finding the server pid was to add a server.pid file next to the server.socket and to use that file on the client if and only if the client platform doesn't support querying for peer PIDs on local sockets. The rest of the port is trivial, adding a clang toolchain entry for freebsd etc. If there is interest in integrating FreeBSD support, I can tidy up the patch and create a review.

Damien Martin-guillerez

unread,
Aug 4, 2015, 4:09:47 AM8/4/15
to Doug Rabson, bazel-discuss
Hello Doug,

Sorry for the late answer, it should be safe to do that change and we are interested. You can send a review request on gerrit (https://bazel-review.googlesource.com).

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/1e3f388e-3118-4d18-80dc-bf1d4de11425%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Han-Wen Nienhuys

unread,
Aug 4, 2015, 4:48:56 AM8/4/15
to Damien Martin-guillerez, Doug Rabson, bazel-discuss
The launcher code is quite subtle, and by its nature hard to test. It
would be great if the server.pid change could be separated out, so we
can let it stress-test it on its own, should it affect the linux code
paths too.
> https://groups.google.com/d/msgid/bazel-discuss/CAN3hOS_PkE6mY%2BTJNH1z00kROJqMfP0ED3N8bUcp54%3DX1bK50Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Han-Wen Nienhuys
Google Munich
han...@google.com

Doug Rabson

unread,
Aug 4, 2015, 5:00:25 AM8/4/15
to bazel-discuss, dmar...@google.com, d...@rabson.org
That makes sense - I'll separate the server.pid change from the rest. In the meantime, I would like to get more of the unit tests to pass - there are a few shell tests where "if darwin; then mac stuff; else linux stuff; fi" should really change to "if not linux; then bsd stuff; else linux stuff".

One other issue that I'm ignoring for now is the pervasive use of '/bin/bash' for shell scripts. FreeBSD doesn't have bash in the base system and the standard bash package installs /usr/local/bin/bash. I think the correct portable approach for this is to change '/bin/bash' to '/usr/bin/env bash' but for now, I've just added a symbolic link on my test system.

Doug Rabson

unread,
Aug 5, 2015, 3:46:24 AM8/5/15
to bazel-discuss, dmar...@google.com, d...@rabson.org
I added a review for the server.pid support (https://bazel-review.googlesource.com/#/c/1771/). Unfortunately I forgot to rebase against today's master branch so gerrit is unhappy with it - its listed as Merge Conflict.

Doug Rabson

unread,
Aug 5, 2015, 5:23:44 AM8/5/15
to bazel-discuss, dmar...@google.com, d...@rabson.org
Also, the patch doesn't work on Linux :(. I will fix it and re-push...

Doug Rabson

unread,
Aug 5, 2015, 2:41:59 PM8/5/15
to bazel-discuss, dmar...@google.com, d...@rabson.org
I uploaded a new patch which should work better on Linux.
Reply all
Reply to author
Forward
0 new messages