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

Fix check to disable LTO by default #192

Merged
merged 1 commit into from
Jun 2, 2020
Merged

Conversation

bradparker
Copy link
Contributor

This got sassc-ruby working for me using Nix on Darwin.

@bradparker bradparker changed the title Fix check to disbale lto by default Fix check to disable LTO by default Mar 24, 2020
@lrworth
Copy link

lrworth commented May 12, 2020

#148 is the original issue for this

@@ -27,7 +27,7 @@
# darwin nix clang doesn't support lto
# disable -lto flag for darwin + nix
# see: https://github.com/sass/sassc-ruby/issues/148
enable_lto_by_default = (Gem::Platform.local.os == "darwin" && !ENV['NIX_CC'].nil?)
enable_lto_by_default = (Gem::Platform.local.os == "darwin" && ENV['NIX_CC'].nil?)
Copy link

Choose a reason for hiding this comment

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

On closer inspection this check is a little weird. Firstly I'm pretty sure nil? is a Rails addition. Secondly this should enable LTO by default unless we are using nix clang on darwin. Maybe:

enable_lto_by_default = !(Gem::Platform.local.os == "darwin" && ENV['NIX_CC'])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for having a look at this :).

I think .nil? "comes standard".

~ $ irb

WARNING: This version of ruby is included in macOS for compatibility with legacy software.
In future versions of macOS the ruby runtime will not be available by
default, and may require you to install an additional package.

irb(main):001:0> nil.nil?
=> true
irb(main):002:0> "".nil?
=> false
irb(main):003:0>

I agree the check is weird and I think your version makes more sense. It reads well: "Enable LTO by default when we're not on Darwin and the nix wrapped C compiler will be used".

Copy link

Choose a reason for hiding this comment

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

Oh sorry about that, you're absolutely right!

Also just to make it more explicit, it looks like in master the only time LTO is automatically enabled is on Darwin with Nix clang, which is the opposite to what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, sorry. The title of my branch / PR is weird :P. In my head it was "Fix check to disable the enabling of LTO by default" ... ergh.

I wonder if there isn't a better way to do this in general. Like to detect if LTO will work without having to know that it won't work for the C compiler wrapped by Nix on Darwin. Like, could it also not work with other C compilers? Is there some way to ask: "is LTO available?".

Until then it'd be good to get something like this merged as I'm sure other Darwin + Nix using Ruby devs are having a head-scratching time.

lrworth referenced this pull request in NetBSD/pkgsrc May 20, 2020
Update to ruby-sassc to 2.3.0.


- **2.3.0**
  - [Fix rake gem:native task](sass/sassc-ruby#196)
  - [disable lto flag for darwin + nix](sass/sassc-ruby#166)
  - [Sort input file list](sass/sassc-ruby#178)
  - [Set appropriate encoding for source_map](sass/sassc-ruby#152)
  - [allow passing functions directly](sass/sassc-ruby#162)
  - [always dispose data context](sass/sassc-ruby#161)
  - [Update libsass to 3.6.3](sass/sassc-ruby#164)
  - [Restore strip symbols](sass/sassc-ruby#184)
  - [Default --march-tune-native to false](sass/sassc-ruby#158)
  - [Fix compile issue on Mac OS X](sass/sassc-ruby#174)
  - [Test on TruffleRuby in TravisCI](sass/sassc-ruby#171)
  - [Use RbConfig::MAKEFILE_CONFIG['DLEXT'] instead of hardcoding extensions](sass/sassc-ruby#173)
@bolandrm
Copy link
Member

bolandrm commented Jun 2, 2020

@glebm could you please review this if you get a moment?

Copy link
Contributor

@glebm glebm left a comment

Choose a reason for hiding this comment

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

Approved accidentally, still reviewing

Copy link
Contributor

@glebm glebm left a comment

Choose a reason for hiding this comment

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

LGTM

@bolandrm bolandrm merged commit 4fce2b6 into sass:master Jun 2, 2020
@pelletencate
Copy link

@bolandrm Care to release this as v2.4.1?

@ywen
Copy link

ywen commented Nov 17, 2020

I double checked. Could you please release the changes in this PR? Thank you!

ywen pushed a commit to ywen/sassc-ruby that referenced this pull request Nov 17, 2020
To include sass#192 into the release
@ywen ywen mentioned this pull request Nov 17, 2020
@lloeki
Copy link

lloeki commented Nov 4, 2021

That last comment was a year ago and the release did not happen 😢

FTR a workaround:

bundle config [--local] build.sassc --disable-lto
bundle install

@kalbasit
Copy link

@bolandrm I ran into this issue as well. Is there any way you can release a new version with the fix?

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

Successfully merging this pull request may close these issues.

8 participants