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

Run the first chapter on a mac #19

Open
Alexis-benoist opened this issue Mar 16, 2015 · 5 comments
Open

Run the first chapter on a mac #19

Alexis-benoist opened this issue Mar 16, 2015 · 5 comments

Comments

@Alexis-benoist
Copy link

Hello,

I don't know if it's the good place to ask, so if I'm wrong don't be mad just tell me :)
I'm running OSX.
I installed llvm using brew and I compiled the first functions using llc.
Now I have a test.s and I don't know how to run it.

I tried the command gcc test.s -o hello.native and I have now the error:
test.s:2:2: error: unknown directive
.macosx_version_min 14, 1

Does anyone knows why?
Thanks

@tiye
Copy link

tiye commented Mar 23, 2015

Same here:

➤➤ cc hello.s -o hello.native
hello.s:2:2: error: unknown directive
 .macosx_version_min 14, 0
 ^

First 4 lines of hello.s:

    .section    __TEXT,__text,regular,pure_instructions
    .macosx_version_min 14, 0
    .globl  _add
    .align  4, 0x90

And after I removed that line .macosx_version_min 14, 0compilation just passed.

@sdiehl
Copy link
Owner

sdiehl commented Mar 23, 2015

I have not used LLVM on a Mac before, so if there is any advice about how to change the wording so that it's Linux and Mac agnostic the Markdown is here and pretty quick to change: https://github.com/sdiehl/kaleidoscope/blob/master/tutorial.md#llvm-introduction

@hellerve
Copy link

The problem is that GCC does not know about the macosx_version_min directive. Clang does. So, if you have gcc installed as your default for gcc or cc, you have to call clang explicitly.

A more serious problem is that on OS X, the current LLVM system default and the version provided by Homebrew are 3.6.0, which has no Haskell bindings yet.

@ayberkt
Copy link

ayberkt commented Aug 13, 2015

If you're using brew, you can install LLVM 3.4 by brew install llvm34. This will install all llvm commands with the -3.4 ending e.g. llvm-config-3.4 for llvm-config. Aliasing llvm-config to llvm-config-3.4 was enough of a hack for me to be able to build llvm-general and llvm-general-pure. But I have still not run the cabal project for myself so I don't know if I will face any other problems.

@doersino
Copy link
Contributor

doersino commented Aug 10, 2016

EDIT: The below is outdated. Simply follow the setup instructions in README.md.


For future visitors: Old versions of Homebrew packages are now maintained here, so in order to install LLVM 3.5 and set up the Kaleidoscope tutorial, perform the following steps (tested on OS X El Cap):

brew tap homebrew/versions
brew install llvm35
brew install libffi  # the version provided in OS X El Cap is too outdated
cabal sandbox init
cabal configure  # or cabal configure --flags=tutorial, see README.md
alias llvm-config='llvm-config-3.5'  # see comment by @ayberkt
cabal install llvm-general-3.5.1.2 --extra-lib-dirs /usr/local/opt/libffi/lib/  # more recent 3.5.*.* versions might work too
cabal install --only-dependencies

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

No branches or pull requests

6 participants