-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal changes to get building on OS X with clang and Homebrew #136
Conversation
Within src directory: make USE_UPNP=1 -j $(sysctl -n hw.ncpu) -f Makefile.osx all
Note also that this is just for building |
This would be obsoleted if #135 is merged |
Update: this was fixed. Safe to merge!
|
PR #108 doesn't break compilation with non-Clang compilers BTW. |
Do we really need gthread? |
The other Makefiles have that, too, but it shouldn't be necessary. My PR that introduces a proper build system doesn't have it and it works :). |
So this does NOT work for Namecoin-QT, correct? |
@indolering Correct. |
I don't expect this to be merged btw. It's just an illustration of the minimal changes needed to build on OS X. |
@taoeffect Yeah, I had it working ~8 months ago, then changes to 10.9 and the switch to Clang broke Boost. |
It seems OS X is even worse than windows in regard to building. Somebody please make it work! With GUI! |
@phelixbtc I got it working with GUI, see my other PR. |
@Midar https://github.com/ceptacle/libcoinqt Interested? |
@phelixbtc could we get this PR request accepted? Namecoind is better than nothing and Midar's other build system isn't going anywhere. |
What's libcoind missing that namecoind has? I like libcoind's build system better (and I got it to build on OS X, I should probably submit a PR for that too...) |
@taoeffect libcoind is missing a few things, including RPC calls for registering names. There's more info on the forum. I might be able to arrange some bounties for getting libcoind up to par with namecoind feature-wise, if that's something you're interested in. |
I wouldn't be able to do it (allergic to C++), but I might be able to chip in. Grumble. What about bitcore? Can it do namecoiny things yet? I think @ryancdotorg was working on that...? |
NM, @ryancdotorg said on IRC that he's not entirely sure what bitcore is... lol. And I can't figure it out either! Is it a liteclient? It doesn't seem to be a full node. |
OK, so figured out what bitcore is thanks to Bitcore is:
Copay is:
Insight-API seems to be:
So... nm about the bitcore. Looks like all we have is |
Sorry for the OT, but I think I should comment here regarding libcoin: Yes, exactly, the missing features are registering names and |
Is there a consensus this is a step in the right direction? @cassiniNMC? @taoeffect Could you give example lines for how to install dependencies with proper versions with homebrew? Why did you not expect this to be merged? |
Like I said, the "proper versions" aren't available on Homebrew, so I used what was available there.
Because this comment. |
@taoeffect OK, we should be able figure these out, thanks! |
@taoeffect Yes, it would be great if you could find out a suitable macro/pragma for that section in serialize.h |
- got rid of gthread + removed a bunch of unused and irrelevant-to-osx stuff from Makefile + no need to specify `USE_UPNP=1`, it is done for you (make sure to install it!) Instructions: 1. `brew install openssl berkeley-db4 boost miniupnpc` 2. cd src && make -f Makefile.osx -j $(sysctl -n hw.ncpu) all
K. This is ready to be merged. I got rid of Compiled and verified. Will crash if you have previously used this PR to run namecoind because of database downgrade to berkeley db 4!!!You have two options:
Or
If you go with the second option, you will need to delete all your database stuff and re-download. You can use my node on okturtles.com to "quickly" get up to speed (I have bandwidth to spare):
Then after it boots up add re-import your private keys that you exported:
(Obviously, the key above isn't a real one, just an example.) |
Also, regarding
If you know your CPU count, you can just use it: |
@domob1812 I decided to not do a |
@taoeffect Considering that this branch on your repo is just a "work in progress", I see no problem with rebasing it. This is also what Bitcoin devs usually want, and it makes the official repo's history cleaner. I think this counts more than following some "supposed to be" Git guidelines to-the-letter. |
@@ -109,12 +109,13 @@ T* alignup(T* p) | |||
return u.ptr; | |||
} | |||
|
|||
#define MSG_NOSIGNAL 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this break Linux builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Um, I don't know. Is __WXMSW__
Windows only? Then maybe there should be a separate ifdef that defines it for OS X?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, autotools should detect if the platform has MSG_NOSIGNAL and define it if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erm, can't that be done with a simple #ifdef
...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if defined(__WXMSW__) || defined(__clang__)
#define MSG_NOSIGNAL 0
#endif
I don't know about a direct define for this. Maybe using 'MAC_OSX' instead of '__ clang __' would be cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's probably safe too -
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 09/19/2014 10:23 AM, phelixbtc wrote:
In src/util.h:
@@ -109,12 +109,13 @@ T* alignup(T* p)
return u.ptr;
}+#define MSG_NOSIGNAL 0
|#if defined(WXMSW) || defined(clang)
#define MSG_NOSIGNAL 0
#endif
This will break build with clang on linux, won't it?
#ifndef MSG_NOSIGNAL
define MSG_NOSIGNAL 0
#endif
is probably safer, albeit not bullet-proof. On Linux, MSG_NOSIGNAL is a enum
value, but it is accompanied with a #define, making it workable (hopefully).
OK, I actually replaced |
Compiles and runs on Windows. ACK. Linux GCC? |
IMO someone should test on Linux GCC before this is merged. Maybe someone can ask pmc to look at it? |
Just because something compiles does not make it correct. With consensus systems, this is even more important of a point. I advise figuring out the actual issue and fixing it specifically. Or at the very least, leave unaffected platforms unchanged. |
Luke raises a good point. Is there any reason to believe one way or the other regarding whether this will affect consensus? |
@luke-jr Are you saying this affects any platform other than mac? |
https://github.com/okTurtles/namecoin/archive/1f4a78a2ab1e973b96fa6edcff4d2dbc04b10ce0.tar.gz compiles with linux/gcc + starts syncing... I don't see why non-OSX builds should be affected by the patch. |
@@ -926,7 +926,7 @@ class CDataStream | |||
void clear() { vch.clear(); nReadPos = 0; } | |||
iterator insert(iterator it, const char& x=char()) { return vch.insert(it, x); } | |||
void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); } | |||
|
|||
#ifdef __APPLE__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change effectively removes the first insert method from the class on non-Apple platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On OS X, the compiler errors because of multiple definitions. I can put the guard around the parameter definition if you'd prefer (as that's the only difference) and delete the duplicate body. Maybe there's a way to define the parameters correctly for all platforms, but again, I have no interest in figuring that out, I just made a few small changes to get it to compile on OS X.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for a guard. Just remove the correct duplicate and it should work with any compiler on any OS.
Maybe there's a way to define the parameters correctly for all platforms, but again, I have no interest in figuring that out, I just made a few small changes to get it to compile on OS X.
Then why bother at all if you only want a quick and dirty hack?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, it might also work to simply show the second definition on all platforms except __APPLE__
, but so far this seems to work just fine (indicating only one definition is needed... per platform).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove the correct duplicate and it should work with any compiler on any OS.
Removing one will break compilation on one of the platforms (regardless of which you remove), if I remember correctly.
Feel free to send your own PR on top of this one if you'd like.
Then why bother at all if you only want a quick and dirty hack?!
...I wanted "minimal changes" to get it to work on OS X. I got them.
It really saddens me a lot to see how much time people spend to place one hack over another. Things like these |
@Midar, I agree with your sentiment with the exception that I believe C++ and autoconf and all that jazz are already hacks by their very nature. |
@taoconf autoconf is not really a hack IMHO. It's the correct way to write portable software: Instead of having checks like "Is this Linux? Is this OSX?", it actually checks if the things it needs are available. That greatly increases portability, as this means it even works on OSes about which the software does not know. The only way where I'd say this is a hack is in that there's nothing integrated with C/C++ that could do these checks, not even a #try_include which would already make a lot of checks unnecessary. As for C++, yes, you could call it a collection of hacks. For each shortcoming of C or an old C++, a new feature was added. But this is how incremental designs work. Not everything is fully planned ahead and then never extended. In fact, almost nothing is. That's still different from adding even more hacks than necessary if there's a proper solution, though ;). Those hacks in C++ are because either a.) backwards compatibility or b.) there's no better way to do it given the constraints. |
IMO, your PR is an even less clean solution (no offense). It's thousands of additional lines that so far no one has taken the time to review. A C++ node is an ugly, dirty, and potentially dangerous hack. There's no getting around that. This is what I tell everyone when they think it's a bright idea to start new projects in C++ these days. They don't listen. Then this crap happens and we spend all this time and effort on getting crappy, ugly, insecure code to run on multiple platforms. Where's the puke emoticon when you need it? The "clean" solution would be to write this in a non-hack language. |
The problem here is not C++, but the lack of a build system that allows to properly check for features. @luke-jr rightfully complained about those #ifdefs you added, as they are OS checks instead of feature checks. Not even do they limit portability to platforms which are known by the source, this is also a guarantee that things will break in an update of the OS. Your #define for example will break if OS X decides it's a good thing to have it and also adds it. There are a lot of use cases where C++ is the right tool. Granted, there are better languages for a cryptocurrency, but C++ really isn't the biggest problem here. A way bigger problem is the mix of Boost and Qt, mixing two giant frameworks. Or that there's a lot of Those additional lines suddenly get down to a really low number if you just compare those files that are taken from autotools with the upstream ones. It gets down to a few hundred lines. Really now, if you don't trust autotools from upstream, you can't trust your system at all. Heck, your compiler uses them, so why even trust your compiler? Anyway, the amount of time spent on this PR is already magnitudes larger than the amount of time that would have been required to review those parts of my PR that are not just copied from elsewhere (and those you can easily diff), while the gain is significantly smaller. |
@Midar Namecoin will be rebased on current Bitcoin / Libcoin. There is a consensus that we will not add a build system at this point. Please take further discussions about this to the forum or make a PR for contrib/ I appreciate all of you staying polite and it may be a bit late as we hopefully are about done here, but still: Everybody please stay on topic. Off topic posts will be deleted from now on. @taoeffect This is just what we needed. Thank you! |
@indolering Sometimes, minimal effort equals to the most dirty solution. While my patch does touch other OSes, it does not break any. In fact, it even increases portability for other OSes. |
Minimal changes to get building on OS X with clang and Homebrew
bccaf86 Merge pull request namecoin#150 2a53a47 Merge pull request namecoin#151 5f5a31f Merge pull request namecoin#149 3907277 Merge pull request namecoin#142 a3e0611 Enable tests in x86 travis builds 45da235 x86 builder 8bb0e93 Merge pull request namecoin#155 971fe81 build: fix openssl detection for cross builds f22d73e Explicitly access %0..%2 as 64-bit so we use the right registers for x32 ABI e66d4d6 Avoid the stack in assembly and use explicit registers cf7b2b4 Fix ECDSA message hashes to 32 bytes 056ad31 Really compile with -O3 by default 74ad63a Merge pull request namecoin#146 9000458 Merge pull request namecoin#145 1f46b00 build: fix __builtin_expect detection for clang aaba2e0 Merge pull request namecoin#136 8a0775c Merge pull request namecoin#144 ee1eaa7 Merge pull request namecoin#141 c88e2b8 Compile with -O3 by default 6558a26 Make the benchmarks print out stats 000bdf6 Rename bench_verify to bench_recovery 7c6fed2 Add a few more additional tests. 992e03b travis: add clang to the test matrix b43b79a Merge pull request namecoin#143 e06a924 Include time.h header for time(). 8d11164 Add some additional tests. 3545627 Merge pull request namecoin#118 6a9901e Merge pull request namecoin#137 376b28b Merge pull request namecoin#128 1728806 Merge pull request namecoin#138 a5759c5 Check return value of malloc 39bd94d Variable time normalize ad86bdf Merge pull request namecoin#140 54b768c Another redundant secp256k1_fe_normalize 69dcaab Merge pull request #139 1c29f2e Remove redundant secp256k1_fe_normalize from secp256k1_gej_add_ge_var. 2b9388b Remove unused secp256k1_fe_inv_all f461b76 Allocate precomputation arrays on the heap b2c9681 Make {mul,sqr}_inner use the same argument order as {mul,sqr} 6793505 Convert YASM code into inline assembly f048615 Rewrite field assembly to match the C version 3ce74b1 Tweak precomputed table size for G git-subtree-dir: src/secp256k1 git-subtree-split: bccaf86caa9c44166e5a66600b742c516e03c3f0
Install dependencies with Homebrew and then from within src directory:
The only concern is how to install specific versions of the dependencies (to avoid accidentally resulting a hard fork).
Unfortunately, I couldn't find "db-4.7.25.NC" via Homebrew. The farthest back they have is 4.8.30. Is that OK?
Also, I haven't tested yet if boost 1.5 builds on OS X or not. 1.55 does, but I'm not sure about 1.5.