-
Notifications
You must be signed in to change notification settings - Fork 468
Use covariant return types in the visitors #382
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
Comments
@akhleung Can you give more details what your specific idea was? |
Give me a couple of days to collect my thoughts -- it's been a while, and I'll need to revisit some of the code in the visitors (no pun intended). |
I found another optimization for prelexer // Tries the matchers in sequence and succeeds if they all succeed.
template <prelexer... mxs>
const char* alternatives(const char* src) {
const char* rslt;
for (prelexer mx : { mxs... }) {
if ((rslt = mx(src))) return rslt;
}
return 0;
}
// Tries the matchers in sequence and succeeds if they all succeed.
template <prelexer... mxs>
const char* sequence(const char* src) {
const char* rslt = src;
for (prelexer mx : { mxs... }) {
if (!(rslt = mx(rslt))) return 0;
}
return rslt;
} |
I'm all for this stuff 👍 but as you said @mgreter
If we head down this track we're quickly going to hit a point of no return for old centos |
@xzyfer IMO this is a pretty neat improvement since it removed about 100 lines of codes and made the |
I'm 100% for this. Just concerned how we'll deal with you're CentOS patch for node-sass /cc @am11 |
Just wondering.. |
Old CentOS is a bad news, kept haunting me for quite some nights. 👻 |
According to https://gcc.gnu.org/projects/cxx0x.html variadic templates have been included since gcc 4.3, so changes are good that it will compile with pretty old gcc and c++0x (which we do with CentOS patch). |
Cool, great news. Just playing devil's advocate :) |
👍 🎉 |
@am11 generally speaking the only reason we're not adopting more C++ 11/14/17 features is for node-sass' CentOS support. |
Down the road, if we get attention from someone expert in build-systems, especially gyp, we probably would be able to distill the Linux binary's moving parts, and link all the required machinery statically. Binary size will grow dramatically (from ~2MB to ~5MB each I suppose?) but, IMO, that tradeoff is worthwhile. Speaking of build-systems, hello @QuLogic! 😎 |
I've done some quick looking into this, and it sounds it should be possible if the binary is compiled on a system with gcc >= 4.5 (http://stackoverflow.com/questions/13636513/linking-libstdc-statically-any-gotchas). Also looks like problem may be node-sass specific? (not sure, maybe)
|
@xzyfer thanks! Is it like diet-glibc that we can statically compile with? Also we would need to static compile libstdc++ as well, which in turn depends on system glibc which is another pain-point. :( PS: I think we cannot compile glibc and libstdc++ together (I read it somewhere). |
/cc @vektah |
@xzyfer There are two nice approaches mentioned here: https://sourceware.org/ml/libc-help/2011-04/msg00034.html Namely:
Resultant executable should run on both new and old versions of glibc. |
Turns out options 2 is pretty damn easy with docker. create a
then run:
The resulting |
Wohoo! |
Surprisingly, it will work. One binary spanning 8 years of linux: Modified Dockerfile:
and same
|
This is brilliant! Thanks. 👍 I tried to compile GCC 4.7 on CentOS 5.5. and 5.11, but it failed. Which version of GCC it installed after |
Wouldn't it make more sense to run something like |
@am11 The curl does not install gcc it just adds another repo
Installs g++ in /opt:
Its not the newest, but it does compile master. @QuLogic I assumed there was a better way of doing that, but didn't go looking. Sadly it does not seem to work:
The docker images are pretty minimal, as you can see I needed to install curl. |
@vektah, yeah I copied the line before. 👎 Incidentally, can we have x86 tooling there as well or should we have a separate Docker image for x86 arch? |
@akhleung I'm going to close this! Please feel free to open a new issue if you have more details! |
Currently there's a lot of downcasting in the visitor methods ... you can get rid of the casts by using covariant return types.
The text was updated successfully, but these errors were encountered: