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

Windows Compat #1

Closed
wants to merge 6 commits into from
Closed

Windows Compat #1

wants to merge 6 commits into from

Conversation

schneems
Copy link
Owner

  • Path separators are platform dependent. We should use a cross platform API when building them.

- Path separators are platform dependent. We should use a cross platform API when building them.
@schneems schneems mentioned this pull request Jul 26, 2016
os: Visual Studio 2015

install:
- set PATH=C:\Ruby22\bin;%PATH%

Choose a reason for hiding this comment

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

Here the version of Ruby is hardcoded, so will always use the same version of Ruby, even that you have different versions in the matrix defined beneath.

Take a look at my sample test package gem:

https://github.com/luislavena/test-ruby-c-extension/blob/master/appveyor.yml

Please note that make in this case is available thanks to rake-compiler and DevKit integration.

If you need just make, take a look to this thread in AppVeyor:

http://help.appveyor.com/discussions/problems/2504-what-is-the-right-way-to-include-the-ruby-devkit

Hope that helps.

@schneems
Copy link
Owner Author

Interesting, so you're saying that Ruby devkit comes with a GCC version of make. In this case the thing I'm having problems with is compiling libass and not the ruby bindings. The project doesn't use rake-compiler. I'm not sure if that's the best way to move forwards. It's in the ext sub dir here https://github.com/schneems/sassc-ruby/tree/master/ext.

The makefile they're using doesn't work for nmake https://github.com/sass/libsass/blob/3ae9a2066152f9438aebaaacd12f39deaceaebc2/Makefile. Which is where I got stuck. They are tested on windows https://github.com/sass/libsass/blob/3ae9a2066152f9438aebaaacd12f39deaceaebc2/appveyor.yml however that is greek to me, I have no idea what's going on other than they're not using nmake.

@xzyfer
Copy link

xzyfer commented Jul 28, 2016

For reference this is where the LibSass Windows compilation happens

      if ($env:Compiler -eq "mingw") {
        mingw32-make -j4 sassc
      } else {
        msbuild /m:4 /p:Configuration=$env:Config sassc\win\sassc.sln
      }

@luislavena
Copy link

That is using a version of mingw just downloaded (in previous step).

I no longer have a Windows machine or involved with RubyInstaller but
DevKit bundled with AppVeyor should be able to compile libsass without
issues.

Sorry for top posting, sent from mobile.

On Jul 28, 2016 02:47, "Michael Mifsud" [email protected] wrote:

For reference this is where the LibSass Windows compilation happens

  if ($env:Compiler -eq "mingw") {
    mingw32-make -j4 sassc
  } else {
    msbuild /m:4 /p:Configuration=$env:Config sassc\win\sassc.sln
  }


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

@schneems
Copy link
Owner Author

schneems commented Aug 2, 2016

Got it building and I believe FFI is finding and using the DLL correctly, however there's a segfault right now:

https://ci.appveyor.com/project/schneems/sassc-ruby/build/17/job/lsdrbpbpr4s4vf9k#L173

C:/projects/sassc-ruby/lib/sassc/engine.rb:39: [BUG] Segmentation fault
ruby 2.0.0p648 (2015-12-16) [i386-mingw32]
-- Control frame information -----------------------------------------------
c:0027 p:---- s:0126 e:000125 CFUNC  :compile_data_context
c:0026 p:0284 s:0122 e:000121 METHOD C:/projects/sassc-ruby/lib/sassc/engine.rb:39
c:0025 p:0034 s:0111 e:000108 METHOD C:/projects/sassc-ruby/test/functions_test.rb:174
c:0024 p:0011 s:0103 e:000102 METHOD C:/projects/sassc-ruby/test/functions_test.rb:92
c:0023 p:0028 s:0100 e:000099 BLOCK  C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest/test.rb:108
c:0022 p:0008 s:0098 e:000097 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest/test.rb:206
c:0021 p:0007 s:0094 e:000093 BLOCK  C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest/test.rb:105
c:0020 p:0019 s:0092 e:000091 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest/test.rb:258
c:0019 p:0007 s:0088 e:000087 BLOCK  C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest/test.rb:104
c:0018 p:0034 s:0086 e:000085 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest.rb:327
c:0017 p:0035 s:0079 E:0013f8 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest/test.rb:278
c:0016 p:0007 s:0073 E:001d44 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest/test.rb:103
c:0015 p:0029 s:0070 e:000069 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-around-0.3.2/lib/minitest/around/unit.rb:11
c:0014 p:0012 s:0066 e:000065 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest.rb:774
c:0013 p:0019 s:0060 e:000058 METHOD C:/Ruby200/lib/ruby/gems/2.0.0/gems/minitest-5.5.1/lib/minitest.rb:301

i'm getting the same thing (in my VM) locally. This is my first time trying to fix a native extension (let alone one on windows). So i'm not sure the best way to debug the segfault. It could be a problem with the compilation, or a problem with how FFI is binding to the dll, or a problem with the ruby code, i'm not sure how to move forwards to narrow down possibilities. Any good resources on where to get started debugging extensions with FFI?

@@ -19,13 +19,13 @@
file "lib/libsass.so" => "Makefile" do
make_program = ENV['MAKE']
make_program ||= case RUBY_PLATFORM
when /mswin/
'nmake'
when /mswin|mingw/
Copy link

Choose a reason for hiding this comment

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

As far as I understand Ruby for Windows DevKits are based on MinGW and Visual Studio should not be used due to various incompatibilities related to the runtime C++ support. Can you try switching to make and the Unix-style build (which is also supported by libsass) and see if that fixes the segmentation fault?

@schneems
Copy link
Owner Author

schneems commented Aug 4, 2016

So it does look like I should switch away from msbuild. I looked around for other ruby gems that work on windows with a native extension and use FFI. I found sqlite3-ruby from @tenderlove which looks like a good blueprint. He is using the rake-compiler gem which seems like most people are leveraging that toolchain.

Development for me is insanely frustrating and slow on a Windows VM. I just finished the provisioning process through Heroku to get a IRL windows laptop. I should have physical hardware soon. I'm out on vacation next week. After that I can come back and I think i'm going to start with basics by making a "hello world" native extension that works on windows and mac/linux (using sqlite3-ruby as a blueprint) then bring that experience back to this project.

Thanks all for the help so far. It's been harder than expected, but i've learned more as well.

@schneems schneems closed this May 13, 2020
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.

4 participants