Skip to content
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

[RFC] Add back gcc 4.4 compatibility #1623

Open
wants to merge 2 commits into
base: 3.4-stable
Choose a base branch
from

Conversation

mgreter
Copy link
Contributor

@mgreter mgreter commented Oct 25, 2015

Since I get quite a few build fails from cpan test matrix for gcc 4.4, I tried how difficult it is to bring back gcc 4.4 compatibility based upon some previous work. It actually is not too hard to get libsass compiled with gcc 4.4 (and passing the spec tests). I want to put this PR into consideration, since I would like to apply the replace-range-for-loops.pl automatically when gcc 4.4 is detected by perl-libsass. Falls under "nice to have", but changes seem rather minimal.

The perl script produces this result: https://github.com/sass/libsass/tree/perl-libsass/gcc-4.4

Proof of concept:

mkdir libsass-gcc-4.4
cd libsass-gcc-4.4
wget -c http://strawberryperl.com/download/5.12.3.0/strawberry-perl-5.12.3.0-portable.zip
mkdir perl
cd perl
unzip ..\strawberry-perl-5.12.3.0-portable.zip
portableshell.bat

git clone https://github.com/sass/perl-libsass.git
cd perl-libsass
git submodule update --init
cd libsass
git remote add mgreter https://github.com/mgreter/libsass.git
git fetch mgreter
git checkout -b compat/gcc-4.4 mgreter/compat/gcc-4.4
perl script\replace-range-for-loops.pl
cd ..
perl -MCPAN -e "CPAN::Shell->notest('install', 'Filesys::Notify::Simple')"
perl -MCPAN -e "CPAN::Shell->notest('install', 'ExtUtils::CppGuess')"
perl -MCPAN -e "CPAN::Shell->notest('install', 'Test::Differences')"
perl -MCPAN -e "CPAN::Shell->notest('install', 'Encode::Locale')"
gcc -v
cpan .

Feedback welcome

@saper
Copy link
Member

saper commented Oct 25, 2015

I have #995 and #996 to for this with autoconf. 4.4 has no issues with variadic templates?

@mgreter
Copy link
Contributor Author

mgreter commented Oct 27, 2015

I was able to get it to compile with gcc 4.4.2, so it seems it had proper support for variadic templates. Tested it via various old strawberry perl portable installs for windows (which come with different gcc toolchains). Might be that I use different cflags on the perl-libsass install, because I think this posed a problem when I tried some time ago.

For documentation here how I compile in the perl portableshell:

git clone http://www.github.com/sass/perl-libsass --branch=latest
cd perl-libsass
cpan . # only needed once for deps
perl Makefile.PL
dmake -P9 test

@ArcticSnowman
Copy link

This is essential to use this module on Centos6 based hosts, in corporate environments

@xzyfer
Copy link
Contributor

xzyfer commented Apr 29, 2016

How so? I routinely build LibSass on centos 5. Updating GCC is trivial
enough.
On 30 Apr 2016 12:53 AM, "Steven Arnott" [email protected] wrote:

This is essential to use this module on Centos6 based hosts, in corporate
environments


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#1623 (comment)

@xzyfer
Copy link
Contributor

xzyfer commented Apr 29, 2016

IMHO we cannot do this without also running GCC 4.4 in CI as well

@ArcticSnowman
Copy link

ArcticSnowman commented Apr 29, 2016

In our corporate environment, we are required to stick to the officially supported Centos6 releases of GCC, which is stuck at 4.4.7. And while there are a whole host of work-around, that's not the route we want our developers to go down if we can help it.

@mgreter mgreter force-pushed the compat/gcc-4.4 branch 14 times, most recently from b9e7d4d to d85d9fd Compare May 1, 2016 20:08
src/ast.hpp Outdated
@@ -309,7 +309,7 @@ namespace Sass {
virtual void adjust_after_pushing(std::pair<Expression*, Expression*> p) { }
public:
Hashed(size_t s = 0) : elements_(ExpressionMap(s)), list_(std::vector<Expression*>())
{ elements_.reserve(s); list_.reserve(s); reset_duplicate_key(); }
{ /* elements_.reserve(s); */ list_.reserve(s); reset_duplicate_key(); }
Copy link
Member

@saper saper May 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#995 adds an autoconf macro here:

+#ifdef HAVE_CXX_UNORDERED_MAP_RESERVE
+      elements_.reserve(s); list_.reserve(s);
+#endif

For non-autoconf builds it stays undefined, so no harm here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordered Map doesn't seem to support it anyway, so I guess this has resolved itself.

@mgreter
Copy link
Contributor Author

mgreter commented May 1, 2016

I have rebased this to latest master and fixed the remaining issue with mac clang. I pretty much would like to get this merged, as it would allow perl-libsass to autodetect this and apply the last "patch" in form of the script in the second commit to the source tree. To get the git tree 4.4 compatible, we would need to get rid of all for(auto el : container) loops, and I actually like that feature a lot. So for me an automated way to "unroll" these loops is good enough.

@ArcticSnowman would that be good enough to support your use case? It does add the dependency on the perl script, but perl should be widely available or you can always generate the gcc 4.4 compatible source tree somewhere else and transfer it (or generate a patch to apply).

Since the proof is in the pudding (libsass via strawberry perl and gcc 4.4.3 on windows):

mkdir libsass-gcc-4.4
cd libsass-gcc-4.4
wget -c http://strawberryperl.com/download/5.12.3.0/strawberry-perl-5.12.3.0-portable.zip
mkdir perl
cd perl
unzip ..\strawberry-perl-5.12.3.0-portable.zip
portableshell.bat

git clone https://github.com/sass/perl-libsass.git
cd perl-libsass
git submodule update --init
cd libsass
git remote add mgreter https://github.com/mgreter/libsass.git
git fetch mgreter
git checkout -b compat/gcc-4.4 mgreter/compat/gcc-4.4
perl script\replace-range-for-loops.pl
cd ..
perl -MCPAN -e "CPAN::Shell->notest('install', 'ExtUtils::CppGuess')"
perl -MCPAN -e "CPAN::Shell->notest('install', 'Test::Differences')"
perl -MCPAN -e "CPAN::Shell->notest('install', 'Encode::Locale')"
gcc -v
cpan .

@saper
Copy link
Member

saper commented May 1, 2016

I also like the short for loops, but I think we should unroll them to avoid issues like somebody adding or changing some loop to the form that cannot be automatically unrolled with a script (like the ones patched above).

@mgreter
Copy link
Contributor Author

mgreter commented May 1, 2016

IMO any code change may add something gcc 4.4 incompatible (I did so with ltrim/rtrim). I guess there are always chances we need to fix up these incompatibilites at a later stage, and I don't see the short for loops as an exclusion here. And as a developer I really would like to keep the convenience.

@xzyfer
Copy link
Contributor

xzyfer commented May 1, 2016

Please a documentation page for compiling with gcc 4.4 which at the very
least documents the Python dependency, the purpose of the Python script,
and it's caveats i.e. naive parsing.
On 2 May 2016 7:11 AM, "Marcel Greter" [email protected] wrote:

IMO any code change may add something gcc 4.4 incompatible (I did so with
ltrim/rtrim). I guess there are always chances we need to fix up these
incompatibilites at a later stage, and I don't see the short for loops as
an exclusion here. And as a developer I really would like to keep the
convenience.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#1623 (comment)

@k-funk
Copy link

k-funk commented May 3, 2016

My shop only supports GCC 4.4.7 on our production machines. I'd love to see this get merged in, and libsass-python library updated when it's ready.

@Roguelazer
Copy link

+1 most production environments aren't going to support gcc5 for a while, it would be nice to keep Saas working without requiring crazy-bleeding-edge versions of things. Enterprise life-cycles are measured in years, not months...

@xzyfer
Copy link
Contributor

xzyfer commented Jul 2, 2016

I'm open to a PR for cpplint style check in CI. With cinema level
guarantees I don't feel comfortable attempting gcc 4.4 support.
On 2 Jul 2016 7:21 AM, "James Brown" [email protected] wrote:

+1 most production environments aren't going to support gcc5 for a while,
it would be nice to keep Saas working without requiring crazy-bleeding-edge
versions of things. Enterprise life-cycles are measured in years, not
months...


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1623 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAjZWHUHOUHRhcCZWDgIXueTHp2TQwNtks5qRYT1gaJpZM4GVJlz
.

@k-funk
Copy link

k-funk commented Mar 9, 2017

Any progress on this, or is it decided to not have 4.4 support?

I don't feel comfortable attempting gcc 4.4 support

Still seems pretty unreasonable that libsass can't be used on CentOS 6 (LOTS of shared-hosting boxes).

@mgreter
Copy link
Contributor Author

mgreter commented Mar 9, 2017

I'm regularly releasing perl-libsass with gcc 4.4 support. The archive contains gcc 4.4 compatible libsass sources (this branch with unrolled for loops). On compatible systems it should also automatically compile and install sassc plus libsass plugins. Unfortunately I wasn't able to convince other libsass maintainers to get this merged into master (see their comments/reasoning above), but you could try to apply the patches in this branch on any implementation (i.e. node-sass). Then you only need to execute perl script\replace-range-for-loops.pl (see example in one of my earlier comment) and compile/install the given implementation.

@mgreter mgreter force-pushed the compat/gcc-4.4 branch 2 times, most recently from 12b785d to a7ee270 Compare April 8, 2017 22:33
@mgreter mgreter force-pushed the compat/gcc-4.4 branch 2 times, most recently from 3d438f1 to 47c834b Compare May 22, 2017 21:08
@mgreter mgreter changed the base branch from master to 3.4-stable October 15, 2017 23:17
@glebm
Copy link
Contributor

glebm commented Apr 15, 2019

Do we still want to deal with non C++ 11 compilers in 2019?

@mgreter
Copy link
Contributor Author

mgreter commented Apr 15, 2019

I will and have updated this branch for perl-libsass and will do so in the future.
As long as the changes needed are manageable of course ...

@glebm
Copy link
Contributor

glebm commented Apr 25, 2019

I'm curious, why does Perl require such an old GCC version?

@mgreter
Copy link
Contributor Author

mgreter commented Apr 26, 2019

I'm curious, why does Perl require such an old GCC version?

There are quite a few CPAN testers that still use 4.4, there are even some that are still on gcc 4.2.
It might not be that many in real life, but it's still nice to have as many green as possible.
Btw. the patches are included in perl-libsass itself and applied automatically if needed.

http://matrix.cpantesters.org/?dist=CSS-Sass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants