Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4557708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:32:47+00:00 2026-05-21T17:32:47+00:00

I am interested in language creation and compiler construction, and have been working through

  • 0

I am interested in language creation and compiler construction, and have been working through the example here: http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/. The author was using LLVM 2.6, and after making a couple changes for LLVM 2.7, I got all the code generation code to compile. When feeding the complier the test code,

int do_math( int a ) {
  int x = a * 5 + 3
}

do_math( 10 )

the program works correctly until it tries to run the code, at which point it segfaults. I am in the process of building LLDB on my system, but it the meantime, anyone see an obvious seg fault in this LLVM asm?

; ModuleID = 'main'

define internal void @main() {
entry:
  %0 = call i64 @do_math(i64 10)                  ; <i64> [#uses=0]
  ret void
}

define internal i64 @do_math(i64) {
entry:
  %a = alloca i64                                 ; <i64*> [#uses=1]
  %x = alloca i64                                 ; <i64*> [#uses=1]
  %1 = add i64 5, 3                               ; <i64> [#uses=1]
  %2 = load i64* %a                               ; <i64> [#uses=1]
  %3 = mul i64 %2, %1                             ; <i64> [#uses=1]
  store i64 %3, i64* %x
  ret void
}

The output is just:

Segmentation fault

My arch is OS X x86_64.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:32:48+00:00Added an answer on May 21, 2026 at 5:32 pm

    I got same problem. I stripped down Loren’s compiler and everything was working fine except execution.

    Segmentation fault was caused by the fact that:

    ExecutionEngine *ee = EngineBuilder(module).create();

    returns NULL. To see the actual error, you need to get error string:

    std::string error;
    ExecutionEngine *ee = EngineBuilder(module).setErrorStr(&error).create();

    In your case you should probably see:

    “Unable to find target for this triple (no targets are registered)

    To fix that you need to call

    InitializeNativeTarget();

    But if you get:

    JIT has not been linked in.

    You should include:

    llvm/ExecutionEngine/MCJIT.h

    which will link JIT engine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm interested in making a language to run on the AVM2 and I'm looking
I have a little problem with the creation of a user control. Though I
I've been mulling over creating a language that would be extremely well suited to
I have recently seen articles on HTML5 and local Db creation and usage. I
Anyone know of an API (php preferable but I'd be interested in any language)
Any programming language. I'm interested in knowing what top 5 methods in a string
In a low level language (C, C++ or whatever): I have the choice in
I am really interested in assembly language and I want to learn about how
I'm interested in learning this language, but it seems that there is very few
I'm mainly interested in the English language characters and punctuation. I need it for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.