Coder Social home page Coder Social logo

ruby-llvm's Introduction

Known Vulnerabilities Code Climate Maintainability Code Climate Issue Count

Ruby-LLVM

Ruby-LLVM is a Ruby language binding to the LLVM compiler infrastructure library. LLVM allows users to create just-in-time (JIT) compilers, ahead-of-time (AOT) compilers for multiple architectures, code analyzers and more. LLVM bindings can also be used to speed up Ruby code by compiling and loading computationally intensive algorithms on the fly.

Current version

This library currently binds to LLVM-18 (specifically llvm-c 18.

About version numbers

The first two digits of ruby-llvm's version number refer to the required major and minor version of LLVM. The third digit refers to the ruby-llvm release itself. Because LLVM's api changes often, this coupling between LLVM and ruby-llvm versions is useful.

Debian/Ubuntu

LLVM Debian/Ubuntu Packages

Homebrew

LLVM can be installed with Homebrew by executing brew install llvm --shared

Source and other binaries

  • LLVM Download Page
  • If compiling from source the --enable-shared and --enable-jit flags may be needed.

See Also

License

Ruby-LLVM is available under the BSD 3-clause (see LICENSE), Copyright (c) 2010-2013 Jeremy Voorhis

Ruby-LLVM is possible because of its contributors:

  • Evan Phoenix
  • David Holroyd
  • Takanori Ishikawa
  • Ronaldo M. Ferraz
  • Mac Malone
  • Chris Wailes
  • Ary Borenszweig
  • Richard Musiol
  • Juan Wajnerman
  • Steven Farlie
  • Peter Zotov
  • Austin Seipp
  • Torsten Rüger
  • Nathaniel Barnes

ruby-llvm's People

Contributors

andrew-dunn avatar booch avatar dependabot[bot] avatar dholroyd avatar eterps avatar ishikawa avatar jvoorhis avatar neelance avatar nekopanic avatar rferraz avatar schuetzm avatar seven1m avatar thoughtafter avatar waj avatar whitequark avatar ymmtmdk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-llvm's Issues

macos (m1): llvm install does not have the required shared libs (hello.rb)

Hi.

Installed llvm on a new macstudio with m1 chip using brew: brew install llvm and set the PATH, etc and was able to get the ruby-llvm to bundle; but when I try hello.rb I get this error:

MacStudio:solana tim$ ruby hello.rb
/Users/tim/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/ffi-1.15.5/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library 'libLLVM-13.so.1': dlopen(libLLVM-13.so.1, 0x0005): tried: 'libLLVM-13.so.1' (no such file), '/usr/local/lib/libLLVM-13.so.1' (no such file), '/usr/lib/libLLVM-13.so.1' (no such file), '/Users/tim/rails/solana/libLLVM-13.so.1' (no such file). (LoadError)

So, I searched the entire file system to set the LD path, but there were no shared (.so) libs for llvm only static (*.a) libs in the filesystem. Searched the net with no joy on how to get ruby-llvm to work with static libs; and also no joy on how to install static libs.

What am I doing wrong or missing?

Thanks.

Can't install on osx 10.9.2

sudo gem install ruby-llvm gives me:

Password:
Building native extensions. This could take a while...
ERROR: Error installing ruby-llvm:
ERROR: Failed to build gem native extension.

/Users/rod/.rvm/rubies/ruby-2.1.1/bin/ruby -rubygems /Users/rod/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.1.0/bin/rake RUBYARCHDIR=/Users/rod/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0/ruby-llvm-3.4.0 RUBYLIBDIR=/Users/rod/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0/ruby-llvm-3.4.0

checking for llvm-config... llvm-config
checking for C++ compiler... rake aborted!
Cannot find C++ compiler: tried ["clang++", "g++"]

Problems running "rake generate_ffi" on Debian.

On Debian Jessie, with LLVM 4.0 installed in /usr/local, I'm trying to run "rake generate_ffi". I've hand edited version.rb and re-run the Rakefile in ext/ruby-llvm-support/ though I'm not sure if any other steps are needed.

When I run "rake generate_ffi", I get:

/usr/include/x86_64-linux-gnu/sys/types.h:146:10: fatal error: 'stddef.h' file not found
rake aborted!

Not sure how to proceed from here.

Full errors:

/usr/include/x86_64-linux-gnu/sys/types.h:146:10:` fatal error: 'stddef.h' file not found
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:573:in `read_declaration'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:346:in `block in declarations'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:338:in `each'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:338:in `each_with_index'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:338:in `declarations'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen/ruby_output.rb:10:in `block in generate_rb'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:150:in `indent'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen/ruby_output.rb:5:in `generate_rb'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:280:in `generate'
/home/perry/.rvm/gems/ruby-2.4.1/gems/ffi_gen-1.2.0/lib/ffi_gen.rb:745:in `generate'
/home/perry/proj/ruby-llvm/Rakefile:44:in `block (2 levels) in <top (required)>'
/home/perry/proj/ruby-llvm/Rakefile:43:in `each'
/home/perry/proj/ruby-llvm/Rakefile:43:in `block in <top (required)>'
/home/perry/.rvm/gems/ruby-2.4.1@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => generate_ffi
(See full trace by running task with --trace)

add support for string attributes

The current attribute API adds and removes enum attributes. Support should be added for string attributes so that target-dependent and attribute-value pair attributes can be used.

https://www.llvm.org/docs/HowToUseAttributes.html

Prior to this work reassessing the attribute API might be worthwhile. The attribute API could be expanded to mimic the C++ API with Attribute and AttributeList objects.

Function 'LLVMAddFunctionAttr' not found in [libLLVM-5.0.so.1] (FFI::NotFoundError)

After a clean install of the latest ref on Ubuntu 18:04 you get Function 'LLVMAddFunctionAttr' not found when you run the provided sample code. I created a Dockerfile for easier testing and clean reproducability.

Steps to reproduce the above mentioned error:

wget https://gist.githubusercontent.com/eterps/59a40746ad09263427274cefaa1409e0/raw/149a21c30873b6e6411ec0c1443730bec96150b3/Dockerfile
docker build -t rbllvmtest . && docker run -it rbllvmtest

(also tested with llvm-4.0, but same error: 'Function 'LLVMAddFunctionAttr' not found in [libLLVM-4.0.so.1] (FFI::NotFoundError)')

Undefined Symbol Error

Hi, I'm trying out ruby-llvm and I'm getting the following error:

/home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ffi-1.9.3/lib/ffi/library.rb:133:in `block in ffi_lib': Could not open library '/home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/libRubyLLVMSupport-3.4.so': /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/libRubyLLVMSupport-3.4.so: undefined symbol: _ZN4llvm3sys14DynamicLibrary7InvalidE (LoadError)
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ffi-1.9.3/lib/ffi/library.rb:100:in `map'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ffi-1.9.3/lib/ffi/library.rb:100:in `ffi_lib'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm/support.rb:17:in `<module:C>'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm/support.rb:8:in `<module:Support>'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm/support.rb:5:in `<module:LLVM>'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm/support.rb:3:in `<top (required)>'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm.rb:5:in `require'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm.rb:5:in `<module:LLVM>'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm.rb:3:in `<top (required)>'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm/core.rb:1:in `require'
    from /home/bryanjos/.rvm/gems/ruby-2.1.1/gems/ruby-llvm-3.4.0/lib/llvm/core.rb:1:in `<top (required)>'
    from main.rb:3:in `require'
    from main.rb:3:in `<main>'

I'm on ubuntu and I built llvm from source with --enabled-shared and I'm using ruby 2.1.1 currently. I basically just made a test project using the hello world example from the samples folder in the repo. Any idea why I'm getting the error?

ruby-llvm can't be installed anymore on Mac with current stable version of Ruby and llvm?

gem install ruby-llvm gives the following error on ruby's current stable version on Mac:

Fetching: rake-10.5.0.gem (100%)
Successfully installed rake-10.5.0
Fetching: ffi-1.9.25.gem (100%)
Building native extensions. This could take a while...
Successfully installed ffi-1.9.25
Fetching: ruby-llvm-3.5.0.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing ruby-llvm:
	ERROR: Failed to build gem native extension.

    current directory: /Users/erik/.gem/ruby/2.5.1/gems/ruby-llvm-3.5.0/ext/ruby-llvm-support
/Users/erik/.rubies/ruby-2.5.1/bin/ruby -rrubygems /Users/erik/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/rake-12.3.0/exe/rake RUBYARCHDIR=/Users/erik/.gem/ruby/2.5.1/extensions/x86_64-darwin-17/2.5.0-static/ruby-llvm-3.5.0 RUBYLIBDIR=/Users/erik/.gem/ruby/2.5.1/extensions/x86_64-darwin-17/2.5.0-static/ruby-llvm-3.5.0
checking for llvm-config... rake aborted!
Cannot find llvm-config: tried ["llvm-config-3.5", "llvm-config"]
/Users/erik/.gem/ruby/2.5.1/gems/ruby-llvm-3.5.0/ext/ruby-llvm-support/Rakefile:24:in `check_for'
/Users/erik/.gem/ruby/2.5.1/gems/ruby-llvm-3.5.0/ext/ruby-llvm-support/Rakefile:29:in `find_llvm_config'
/Users/erik/.gem/ruby/2.5.1/gems/ruby-llvm-3.5.0/ext/ruby-llvm-support/Rakefile:53:in `<top (required)>'

llvm-config is installed though:

which llvm-config
/usr/local/opt/llvm/bin/llvm-config
/usr/local/opt/llvm/bin/llvm-config --version
6.0.1

Steps to reproduce

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ curl -s https://www.ruby-lang.org/en/downloads/ |grep -i 'stable version'
The current stable version is 2.5.1.
$ brew install ruby-install
$ ruby-install ruby-2.5.1
$ brew install chruby
$ source /usr/local/opt/chruby/share/chruby/chruby.sh
$ chruby 2.5.1
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
$ brew install llvm --shared
$ export PATH="/usr/local/opt/llvm/bin:$PATH"
$ gem install ruby-llvm

LLVM 3.3 compatibility

I've experimented with 3.3 compatibility within a branch. There are two problems:

  • Tests segfault in test_module.rb#test_dump (why?! no idea)
  • LLVM::Target.init_native is broken.

Both can be a problem with Ruby 2.0, LLVM 3.3 nightlies or our code. (In particular, I think that the second problem is an LLVM bug.)

I'll wait until @jvoorhis sets up the CI to investigate the problem, and possibly for 3.3 to become more mature.

No way to create constants of named structure type

LLVM features disjoint named and unnamed type "name"spaces: { i32 } and %foo = type { i32 } are distinct and incompatible types. Further, the values of these types (as opposed to pointers to these values) cannot be bitcast one to another.

Currently, there is no way to create the following LLVM IR with ruby-llvm:

%foo = type { i32 }
@FOO = global %foo { i32 1 }

as the LLVM::ConstantStruct.const constructor implicitly creates an unnamed aggregate type derived from the types of its arguments.

Better error handling

There are errors which can cause segfaults in the C functions. These should be guarded and tests added. Off the top of my head one is extract_element out of bounds error which can easily be checked. Probably extract/insert functions should be checked. Also, using call instruction on non-function.

Add api for call site attributes

void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
                              LLVMAttributeRef A);
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
                               LLVMAttributeRef *Attrs);
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
                                              LLVMAttributeIndex Idx,
                                              unsigned KindID);
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
                                                LLVMAttributeIndex Idx,
                                                const char *K, unsigned KLen);
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
                                     unsigned KindID);
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
                                       const char *K, unsigned KLen);

Community development and release process

While we're transitioning to the new Github organization, this is the perfect time to discuss our process for collaboration. Here is what I propose:

  • For each new release, create a milestone in GH issues and populate it with tickets.
  • Work on a fork of ruby-llvm/ruby-llvm or in a local branch.
  • Issue a pull request against ruby-llvm/ruby-llvm master.
  • Verify that the changes are successful and close the issue.

I would like to continue tracking LLVM's release cycle, with a new release trailing each LLVM release using the LLVM version number as the first two digits of the ruby-llvm version, and subsequent releases updating the patch version.

That said, I'm open to any suggestions from the community that improve quality, efficiency or fun.

Recommended LLVM installation/configuration

Given I'm trying to write an LLVM frontend for my language (Rip), how should I install LLVM? Specifically I have an AST, and I wish to compile to LLVM IR. Should LLVM's source be included in the language's codebase?

I installing LLVM with Homebrew several months ago, but I couldn't get it working ("hello world" C++ files wouldn't compile). Yesterday I compiled LLVM from source. I followed the official instructions. The binaries and libraries are in a non-standard location (/Users/thomas/Code/llvm/build/Debug+Asserts/{bin,lib}; I didn't know where to put them).

I realize the questions above are likely outside the scope of ruby-llvm, but I don't know where else to turn to. (@evanphx I'm the guy that talked to you about Rubinius' architecture and compilers on the last day of RubyConf 2014.) Below is the output when attempting to install ruby-llvm.

$ gem install ruby-llvm
Fetching: rake-0.9.6.gem (100%)
Successfully installed rake-0.9.6
Fetching: ruby-llvm-3.4.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-llvm:
    ERROR: Failed to build gem native extension.

    /usr/local/opt/rbenv/versions/2.1.1/bin/ruby -rubygems /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/bin/rake RUBYARCHDIR=/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/ruby-llvm-3.4.0 RUBYLIBDIR=/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/ruby-llvm-3.4.0
checking for llvm-config... rake aborted!
Cannot find llvm-config: tried ["llvm-config-3.4", "llvm-config"]
/usr/local/var/lib/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/Rakefile:24:in `check_for'
/usr/local/var/lib/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/Rakefile:29:in `find_llvm_config'
/usr/local/var/lib/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/Rakefile:50:in `<top (required)>'
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0 for inspection.
Results logged to /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/ruby-llvm-3.4.0/gem_make.out

Update to LLVM-6

I tried a "simple" upgrade of bindings to LLVM-6 and it seems that all JIT tests segfault which is pretty nasty. Of course, not all users need JIT and might be interested in just having updated bindings.

One of the big issues moving forward and maintaining this library is that Ruby-LLVM was built using FFI-Gen which is broken for LLVM releases after 4 and has not been updated since Jan 2015. See my bug report here: neelance/ffi_gen#42

So fixing FFI-Gen would make this project much easier to maintain moving forward, but that's an additional task.

Port chriswailes changes from jvoorhis/ruby-llvm#5

Chris Wailes had some very good changes which were unfortunately difficult to merge, especially after changing our strategy for managing LLVM bindings to ffi_gen. The pull request is at jvoorhis/ruby-llvm#5 and includes:

  • Support for non-x86 targets (if available)
  • Support for additional passes
  • Support for additional instructions
  • Support for additional constant operations

Build Issue -- LLVM3.5 dependency

This library currently binds to LLVM-10 (specifically llvm-c 10).

Then why llvm-config-3.5 (at least from the rake build log) is needed?

Cannot find C++ compiler

I confirmed that I have a clang++ command available on my system. Any ideas?

$ clang++ --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix

Here's the error:

$ gem install ruby-llvm
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-llvm:
    ERROR: Failed to build gem native extension.

    /usr/local/opt/rbenv/versions/2.1.1/bin/ruby -rubygems /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/bin/rake RUBYARCHDIR=/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/ruby-llvm-3.4.0 RUBYLIBDIR=/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/ruby-llvm-3.4.0
checking for llvm-config... llvm-config-3.4
checking for C++ compiler... rake aborted!
Cannot find C++ compiler: tried ["clang++", "g++"]
/usr/local/var/lib/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/Rakefile:24:in `check_for'
/usr/local/var/lib/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/Rakefile:44:in `find_cxx'
/usr/local/var/lib/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0/ext/ruby-llvm-support/Rakefile:51:in `<top (required)>'
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/ruby-llvm-3.4.0 for inspection.
Results logged to /usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/ruby-llvm-3.4.0/gem_make.out

Type must be provided to call2

when running samples/fp.rb (ruby-llvm version 17.0.0)

/Users/femtozheng/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/ruby-llvm-17.0.0/lib/llvm/core/builder.rb:948:in `call2_infer_function_and_type': Type must be provided to call2 when function argument is not a function type: ptr %0 (ArgumentError)

      raise ArgumentError, "#{msg} #{fun}" if !fun2.is_a?(Function) && type.nil?
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /Users/femtozheng/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/ruby-llvm-17.0.0/lib/llvm/core/builder.rb:957:in `call2'
        from /Users/femtozheng/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/ruby-llvm-17.0.0/lib/llvm/core/builder.rb:938:in `call'
        from samples/fp.rb:29:in `block (2 levels) in <main>'
        from /Users/femtozheng/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/ruby-llvm-17.0.0/lib/llvm/core/value.rb:164:in `build'
        from samples/fp.rb:28:in `block in <main>'
        from /Users/femtozheng/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/ruby-llvm-17.0.0/lib/llvm/core/module.rb:180:in `add'
        from samples/fp.rb:27:in `<main>'

	

Add Interface to LLVMParseIRInContext

/**
 * Read LLVM IR from a memory buffer and convert it into an in-memory Module
 * object. Returns 0 on success.
 * Optionally returns a human-readable description of any errors that
 * occurred during parsing IR. OutMessage must be disposed with
 * LLVMDisposeMessage.
 *
 * @see llvm::ParseIR()
 */
LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
                              LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM,
                              char **OutMessage);

Gem release for LLVM 3.3

The current Gem releases seem to use LLVM 3.0 or 3.2 (if you install the beta releases). It would be great if a Gem could be pushed that uses LLVM 3.3 as well. Right now I have to install from source which is fine while hacking along, but this doesn't really work if you want to push your own code to RubyGems at some point.

Thanks!

problems building with LLVM 4.0 on macOS

On macOS, having installed LLVM 4.0 using macports, if I
run "rake", in ext/ruby-llvm-support/ I get

ld: library not found for -lLLVM-4.0

and the build dies.

I got past that in a cheesy way (I cut and pasted the g++ build
line and hand-edited -lLLVM-4.0 to -lLLVM) and then I used otool to
check that the resulting libRubyLLVMSupport-4.0.dylib was pointing to
the correct libLLVM (it is).

I then went off to run "rake generate_ffi" and got:

rake aborted!
LoadError: Could not open library 'libclang-3.5.so.1': dlopen(libclang-3.5.so.1, 5): image not found.
Could not open library 'libclang-3.5.so.1.dylib': dlopen(libclang-3.5.so.1.dylib, 5): image not found.
Could not open library 'libclang.so.1': dlopen(libclang.so.1, 5): image not found.
Could not open library 'libclang.so.1.dylib': dlopen(libclang.so.1.dylib, 5): image not found.
Could not open library 'clang': dlopen(clang, 5): image not found.
Could not open library 'libclang.dylib': dlopen(libclang.dylib, 5): image not found

This seemed rather weird to me, since the string "3.5" doesn't appear
anywhere in the ruby-llvm sources I have.

Problems building on mac

Closely related to #53, I'm having trouble building on mac. I installed llvm-4.0 through brew, but I encounter the following error when running bundle install:

ld: library not found for -lLLVM-4.0

For what it's worth, I poked at the compilation command and found that changing the flag to -lLLVM doesn't throw an error. Might be useless info - I don't really know how gems are written.

Is there anything I can do to get this working? I know this project isn't really active, but I'm happy to use an old version of llvm.

Thanks in advance 🌳

MCJITCompiler broken, tests failing

I'm not sure if this project it still active but I'm finding it really useful for a project I'm working on. I want to thank everyone for their hard work so far.

What I noticed is that MCJITCompiler is broken, it segfaults and has other strange behavior. I checked out the current code to run tests and found that they segfault on my machine after this commit:
9d08bf9

I'm wondering if it is possible to get MCJITCompiler working using the current code or is the problem deeper than that?

Is the project abandoned?

Is this project abandoned? I'd like to use it for some work I'm doing (a compiler front end prototype written in Ruby) but I need it to work with LLVM 4.0. Will I have to update it myself for that to happen?

If so, could someone give me a hint of what might be involved in doing that? There isn't much internal documentation in the code.

Cannot run `rake`

I'm trying to debug an issue (#37, #40) that is preventing me from installing ruby-llvm on OSX, but I cannot run rake. I tried $ bundle exec rake -T; output is below.

rake aborted!
cannot load such file -- llvm/config
/Users/thomas/Code/rip-ruby-llvm/Rakefile:7:in `require'
/Users/thomas/Code/rip-ruby-llvm/Rakefile:7:in `<top (required)>'
(See full trace by running task with --trace)

I checked, and llvm/config.rb doesn't exist. Additionally the generate_ffi task references a constant LLVM::CONFIG::CFLAGS around line 47, which I couldn't find a definition for.

Out of date documentation

Change documentation to reflect current best practices for using the gem. I suspect probably a homebrew/linuxbrew section and and dpkg/apt (debian/ubuntu/mint) section. Instructions on how to use the current gem with LLVM-5.

zeroPaddedFilemode: contains zero-padded file modes

$ git fsck
warning in tree 4e90318c20cb7f50b10489c84550b17519eff88c: zeroPaddedFilemode: contains zero-padded file modes

$ git cat-file -p 4e90318c20cb7f50b10489c84550b17519eff88c
040000 tree 36bc7cb471e93a6eb114db4fe1f4adb9fde24318	lib
040000 tree 16c8a0891ea4789aaf9540752a2d14b2cd95644c	samples

Explanation: https://stackoverflow.com/a/56509224

So we have these zero padded file modes on 2 files from early in the repo history. This can be fixed with an export and import, but that will likely change a lot of hashes.

It has been stated that there is no easy fix for this issue: ohmyzsh/ohmyzsh#9665

Update for LLVM 3.4

With LLVM 3.4 out of the door it would be nice if ruby-llvm were to be updated to support this version too. Right now if you try to install the latest ruby-llvm it will fail installation if LLVM != 3.3 is installed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.