Code Monkey home page Code Monkey logo

Comments (12)

bew avatar bew commented on August 24, 2024 4

It's because crystal-lang/crystal#7282 moved Crystal::Codegen::Target somewhere where it's not required when doing require "compiler/crystal/crystal_path"..
One way to fix this would be to stop requiring tiny parts of the compiler and just require everything with require "compiler/crystal/**" but I personally don't like it..

Until then, we can require "compiler/crystal/codegen/target" before requiring crystal_path:

diff --git a/src/scry/completion_provider.cr b/src/scry/completion_provider.cr
index 29e0d36..f67438c 100644
--- a/src/scry/completion_provider.cr
+++ b/src/scry/completion_provider.cr
@@ -1,4 +1,5 @@
 require "./log"
+require "compiler/crystal/codegen/target"
 require "compiler/crystal/crystal_path"
 require "./completion/*"

diff --git a/src/scry/parse_analyzer.cr b/src/scry/parse_analyzer.cr
index d87eca4..bbe9ed5 100644
--- a/src/scry/parse_analyzer.cr
+++ b/src/scry/parse_analyzer.cr
@@ -1,4 +1,5 @@
 require "compiler/crystal/syntax"
+require "compiler/crystal/codegen/target"
 require "compiler/crystal/crystal_path"
 require "./workspace"
 require "./text_document"

WDYT @crystal-lang-tools/scry ?

from scry.

MelvIsntNormal avatar MelvIsntNormal commented on August 24, 2024

Until then, we can require "compiler/crystal/codegen/target" before requiring crystal_path

This doesn't seem to work for me:

➜ shards build -v
Dependencies are satisfied
Building: scry
crystal build -o /home/melvisntnormal/.cache/sources/scry/bin/scry src/scry.cr
Error target scry failed to compile:
Error in src/scry.cr:4: while requiring "./scry/context"

require "./scry/context"
^

in src/scry/context.cr:7: while requiring "./parse_analyzer"

require "./parse_analyzer"
^

in src/scry/parse_analyzer.cr:2: while requiring "compiler/crystal/codegen/target"

require "compiler/crystal/codegen/target"
^

in /usr/lib/crystal/compiler/crystal/codegen/target.cr:1: while requiring "llvm"

require "llvm"
^

in /usr/lib/crystal/llvm.cr:1: while requiring "./llvm/**"

require "./llvm/**"
^

in /usr/lib/crystal/llvm/di_builder.cr:1: while requiring "./lib_llvm"

require "./lib_llvm"
^

in /usr/lib/crystal/llvm/lib_llvm.cr:1: expanding macro

{% begin %}
^

in /usr/lib/crystal/llvm/lib_llvm.cr:4: error executing command: [ -n "$LLVM_CONFIG" ] && command -v "$LLVM_CONFIG" || command -v llvm-config-6.0 || command -v llvm-config60 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 6.0*) command -v llvm-config;; *) false;; esac)) || command -v llvm-config-5.0 || command -v llvm-config50 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 5.0*) command -v llvm-config;; *) false;; esac)) || command -v llvm-config-4.0 || command -v llvm-config40 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 4.0*) command -v llvm-config;; *) false;; esac)) || command -v llvm-config-3.9 || command -v llvm-config39 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.9*) command -v llvm-config;; *) false;; esac)) || command -v llvm-config-3.8 || command -v llvm-config38 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.8*) command -v llvm-config;; *) false;; esac)) || command -v llvm-config
                  , got exit status 1

                  `[ -n "$LLVM_CONFIG" ] && command -v "$LLVM_CONFIG" || \
                  ^

from scry.

bew avatar bew commented on August 24, 2024

@MelvIsntNormal it works for me, so there's probably something wrong with your install.

Do you have llvm installed? Do you have a llvm-config program?

What's the output of this (loong) shell command:

[ -n "$LLVM_CONFIG" ] && command -v "$LLVM_CONFIG" || \
command -v llvm-config-6.0 || command -v llvm-config60 || \
(command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 6.0*) command -v llvm-config;; *) false;; esac)) || \
command -v llvm-config-5.0 || command -v llvm-config50 || \
(command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 5.0*) command -v llvm-config;; *) false;; esac)) || \
command -v llvm-config-4.0 || command -v llvm-config40 || \
(command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 4.0*) command -v llvm-config;; *) false;; esac)) || \
command -v llvm-config-3.9 || command -v llvm-config39 || \
(command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.9*) command -v llvm-config;; *) false;; esac)) || \
command -v llvm-config-3.8 || command -v llvm-config38 || \
(command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.8*) command -v llvm-config;; *) false;; esac)) || \
command -v llvm-config

from scry.

MelvIsntNormal avatar MelvIsntNormal commented on August 24, 2024

@bew thanks, turns out I didn't have LLVM, once that was installed the build worked as expected

from scry.

bmulvihill avatar bmulvihill commented on August 24, 2024

@bew yeah I don't think we want to include the entire compiler, we did that in the past. Here was the PR that removed it #53

Scry needs to updated to be compatible w/ 0.28.0 I think, we are only on 0.27.0, which should fix this issue (and maybe others).

from scry.

bew avatar bew commented on August 24, 2024

@bmulvihill require "compiler/crystal/**" won't necessarily put the whole compiler inside scry, it just means that all the compiler files will be made available in the global namespace (and it'll put some pressure during scry compile time also...).
And I don't like that when you only need a tiny part of the compiler (here, crystal_path)

from scry.

absolutejam avatar absolutejam commented on August 24, 2024

I'm still hitting this on macOS and Manjaro Linux. LLVM installed, llvm-config in path. Is there an easy fix?

Thanks!

from scry.

bew avatar bew commented on August 24, 2024

Same crystal version and llvm version as the OP?

Did you tried adding the lines mentioned in #155 (comment) ?

from scry.

iambudi avatar iambudi commented on August 24, 2024

I have the same issue compiling using 0.30 on OSX. What branch has the fix?

Error target scry failed to compile:
Showing last frame. Use --error-trace for full trace.

In /usr/local/Cellar/crystal/0.30.0/src/compiler/crystal/config.cr:37:24

 37 | @@default_target : Crystal::Codegen::Target?
                         ^-----------------------
Error: undefined constant Crystal::Codegen::Target

from scry.

bararchy avatar bararchy commented on August 24, 2024

@bew Can we get this fix merged? I get the same issue

from scry.

iambudi avatar iambudi commented on August 24, 2024

Recloning the repo and build it. The error still exists.
Crystal 0.30.1 (2019-08-13)
LLVM: 8.0.1
Default target: x86_64-apple-macosx

from scry.

bew avatar bew commented on August 24, 2024

@iambudi I know, I did a PR #158 but I can't get the ci to work... (no idea how to fix, and no time to debug right now)

from scry.

Related Issues (20)

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.