FreeBSD support for FoundationDB

Ok, I’ll give that a try you can find my branch here- just updated the directions in the readme. Also added a small build change for MacOS if you want to run client as remote or local. It’s different than whats in ports because it actually monitors the system stats while the one in ports sets many values to ‘0’ currently and ports does not have any bindings. Still working on the full set of symbols for libc++ though.

1 Like

Sorry, meant that last comment as an actual reply…also a PR with the full history on this is here too btw:

Cool; adding this to binding.gyp is all that was needed to get the nodejs binding compiling on freebsd (now merged into node-foundationdb master):

        ['OS=="freebsd"', {
          'include_dirs': ['/usr/local/include'],
          'link_settings': { 'libraries': ['-lfdb_c', '-L/usr/local/lib'] },

Of course, to make this work you need the header files installed in /usr/local/include/foundationdb and in /usr/local. Once I re-publish, npm install foundationdb should work out-of-the-box on freebsd. For some reason invoking node-gyp directly is erroring, but npm run install works fine. Eh.

It took a bit of work to actually get a server running - I manually patched PREFIX out of fdbmonitor.cpp to get it building; but now its working I can connect to foundationdb locally from nodejs! :tada:

Once the dust has settled I’d like to add freebsd prebuilds like I’ve done with linux, windows and mac. That would remove the local compilation step from the node module. But to make that work we’ll need a freebsd CI server somewhere. And you’ll still need a compatible copy of installed at runtime. So its probably not a huge priority.

Anyway, awesome work! I’m looking forward to everything getting merged, and gaining official FreeBSD support!

1 Like

Just a quick update here- pretty close to finishing this up for a final code review but just need to do a couple of things. The first is figuring out how to translate the default compiler (clang) environment variable into something the linker build scripts use more effectively. It should be more similar to Darwin and Linux but FreeBSD can be so minimal that a lot of things (e.g. Bash) are considered extras and not standard. The second is getting this on real hardware where there is some good news and bad news. Really want to run this on metal before signing off on it. I didn’t look at the fine print of the hardware allowance I have so that purchase order goes in during the month of October as it turns out. In the meantime I found a Dell micro computer with SSD storage which I’m hoping can do the job. The government where I’m located is doing their fiscal budgets for next year so I have been super busy with work stuff but still committed to moving forward on this and other things FoundationDB related.

1 Like

Right now FreeBSD support is sort of at a crossroads. I’ve been having a bit of bad luck with getting my hands on hardware quickly. This unit the Inspiron 3050 ended up being defective. Here it is sitting on my desk and came across that nobody was using it for anything currently. It cannot even run Windows so I found out pretty soon why everyone was fine letting me temporarily do something with it. :face_with_raised_eyebrow:


It’s pretty rare to come across someone in my position. I’ve had hardware thrown at me by employers since 2010. Have an obvious preference for Apple hardware but really I’ll work on what you give me. How it fits into gov is that it’s the most secure mobile platform. That’s the utility it provides however our contracts are with Microsoft so I code in C#. The Apple hardware also requires less maintenance costs all around and they honor their RMA/Return policies so you actually save money going with them. Ever since mobile we need a single machine which can do Web, Native, Android, and iOS. It’s up to individual depts which devices they go with so it gives them the most freedom. Apple wins again hands down. Using FreeBSD on and off for personal projects since 1998 ended up giving me the most knowledge about Apple all around thus I maintain all of them for our team mostly.

I’m ready to pull the trigger on some hosting and have it down to either Digital Ocean or Vultr. Any experience with either and FreeBSD is greatly appreciated. There are some bad reviews about Digital Ocean from '15 all over various forums and if it wasn’t for that I would go with them. Most of my friends use them for Linux and give them rave reviews. Vultr has a good reputation for FreeBSD and I like their .iso image plan too so leaning more towards them. Getting decent hardware immediately around here is difficult so I will just need to budget that out. More importantly though we need to set up CI. Development is really starting to pick up now and pen testing can be inefficient but it’s really helping me to figure out what parts of FDB are interrelated. The bindings right now are not working and about to roll back some changes I made there until I can figure out the cause- there is an open question about that on GH right now. It boils down to trimming this down or somehow removing this:

lib/libc++.a: $(shell $(CC) -print-file-name=libc++_p.a)
@echo "Frobnicating   $@"
@mkdir -p lib
@rm -rf .libc++
@mkdir .libc++
@(cd .libc++ && ar x $<)
@for i in .libc++/*.o ; do \
	nm $$i | grep -q \@ || continue ; \
	nm $$i | awk '$$3 ~ /@@/ { COPY = $$3; sub(/@@.*/, "", COPY); print $$3, COPY; }' > .libc++/replacements ; \
	objcopy --redefine-syms=.libc++/replacements $$i $$ && mv $$ $$i ; \
	rm .libc++/replacements ; \
	nm $$i | awk '$$3 ~ /@/ { print $$3; }' > .libc++/deletes ; \
	objcopy --strip-symbols=.libc++/deletes $$i $$ && mv $$ $$i ; \
	rm .libc++/deletes ; \
@ar rcs $@ .libc++/*.o
@rm -r .libc++

Probably going to take it one step at a time trying to really understand what the connection with the bindings is if any at all. The philosophy I go by is that if I’m not sure what a small part of something does assume I don’t understand any of it and ask questions about it as if I’m totally lost. I was instructed what to do about it- this is me just double checking are you sure?

As far as creating a brand new “web stack” this met an untimely end there just is not that much interest. Tried my hand at grassroots promotion which just went sideways in my opinion. The silver lining is though when putting some of this stuff together (Dynamic Tuples and GRPC with C#, NGINX static hosting with NetFlix settings for OCA) the performance is sooo good I’d like to keep it for MediaMasters LLC an established family business I’m trying to breathe new life into. The same goes for FoundationDB it’s really good on this platform but I’d like to keep that the same and focus on just that right now getting a POC. Trying to win the hearts of everyone in BSD land is just something I’m not up to. It frees us up creatively to get the competitive edge however (e.g. KAIO). Working with some top dollar SEO’s previously gave me the hutzpah to try my hand at self promotion. It went…badly :smirk: @josephg I think has the right stuff for this if he chose to be a tech evangelist and is obviously a highly skilled developer. FreeBSD organization would be super lucky to have him promoting anything for them.

And back now to C# and FreeBSD :exploding_head: Dynamic Tuples you say? This is a concept inside a project called “Magic Onion” hmm how do I describe this in relation to FoundationDB:

Talk about a great pairing! Everything in FoundationDB is a Tuple so I’m talking high level concepts here. This thing sends messages through GRPC with MessagePack + Protobuf. Yes indeed I got it running on FreeBSD- check it out if you wish. All of this being managed by System.Net.IO.Pipelines would be pretty stunning. Hopefully this screen is enough to pique some interest. More spare parts from the web stack idea.

@KrzysFR recently let me know FoundationDB is heading towards .Net Core which is currently in progress as a Google Summer of Code project. Ironically, I was the developer that kicked off using their new bootstrap CLI method for porting .Net Core to new OS’s working with Eric Mellinoe from Microsoft. Even more ironic it was like after Mr. Mellinoe and I hit a wall Microsoft and FreeBSD organization cloned a better looking version of myself and it got assigned to him formally (I’m kidding of course). Small world huh? Our biggest blocker is this right now. So if I was a betting man :thinking: No, seriously I may join the fight to make this happen. Any thoughts on that are greatly appreciated as well.

So now that I’m trying to reign this in hopefully these posts won’t seem rant-like (the -v flag is set permanently in my brain) and we can focus on one thing at a time going forward and just the technical stuff. Lesson learned on that one. Oh yeah, and one last thing Joyent’s VPC is distributed for FreeBSD. Now this can finally hang with the trend towards distributed in the datacenter. Pushing this project in that direction would validate the work that’s been done so far much more.

I looked at this again and rolled it back looks like libc++.a is definitely needed for the bindings for now.

As for the GRPC stuff I mentioned it’s actually happening and being worked on currently:

I’ll be moving forward with implementing @josephg’s NodeJS bindings into any sites hosted with NGINX and utilizing FoundationDB as the backend which I’m very excited about. There is still a little work to be done before the PR is complete. Sometimes its easy to take for granted how much sheer luck can be on your side when moving forward until it isn’t- is what I’ll say about that. It was a hard call until the news that much of what I was experimenting with will be there later on without having to develop any of it myself- HTTP/2 is progressing on its own at a pretty fast pace.

Rather than asking questions in this post here is some food for thought for the Linux developers out there. It was discussed at BSDCAN2018 conference briefly Linux is changing so much that some problems are emerging running Linux software on FreeBSD. Apparently, there are some new testing procedures which in theory would not allow full validation of Linux software on FreeBSD by just what they call “patching up”. I was watching this session and heard it being discussed:

I’m interested to know more what that means I don’t think I fully grok what the full impact of that will be.

Thanks to the guidance provided by @alexmiller we were able to get to the bottom of the bindings and linking to libc++ and it’s stripped symbols. Seems like he’s on a roll lately :clap:

It came down to this:

Moving forward I’ll probably start posting separate questions now outside this mega-thread but determining development ergonomics, cleaning up the build some more, and re-testing a couple metrics. If anybody has any particular images or ISOs they use to build up their development environment with FreeBSD please let me know and I’ll check it out- thanks again.

1 Like