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 9203583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:30:18+00:00 2026-06-17T23:30:18+00:00

Summary: llvm-ld has been removed from the LLVM 3.2 release . I am trying

  • 0

Summary: llvm-ld has been removed from the LLVM 3.2 release. I am trying to figure out how to use clang in its place in my build system.

Note that I figured out the answer to my own question while writing it but I am still posting it in case it is useful to anyone else. Alternative answers are also welcome.

Details:

I have a build process which first generates bitcode using clang++ -emit-llvm. Then I take the bitcode files and link them together with llvm-link. Then I apply some standard optimization passes with opt. Then I apply another custom compiler pass with opt. Then I apply the standard optimization passes again using opt a third time. Finally I take the output from the last run of opt and use llvm-link to link with appropriate libraries to generate my executable. When I tried to replace llvm-link with clang++ in this process I get the error message: file not recognized: File format not recognized

To make this question more concrete I created a simplified example of what I am trying to do. First there are two files that I want to compile and link together

test1.cpp:

#include <stdio.h>

int getNum();

int main()
{
  int value = getNum();
  printf("value is %d\n", value);
  return 0;
}

test2.cpp

int getNum()
{
  return 5;
}

I executed the following sequence of commands:

clang++ -emit-llvm -c test1.cpp test2.cpp
llvm-link -o test.bc1 test1.o test2.o 
opt test.bc1 -o test.bc2 -std-compile-opts

(Note that I am currently running llvm 3.1, but I’m trying to figure out the steps that will work for llvm 3.2. I assume that I should be able to make the LLVM 3.1 version work correctly using clang instead of llvm-ld)

Then if I run:

llvm-ld test.bc2 -o a.out -native

everything is fine and a.out prints out 5.

However, if I run:

clang++ test.bc2 -o a.out

Then I get the error message:

test.bc2: file not recognized: File format not recognized clang-3:
error: linker command failed with exit code 1 (use -v to see invocation)

Obviously I know that I can produce an executable file by running clang directly on the .cpp files. But I’m wondering what the best way to integrate clang with opt is.

  • 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-06-17T23:30:19+00:00Added an answer on June 17, 2026 at 11:30 pm

    The test case described in the question can be compiled using the following steps:

    clang++ -emit-llvm -c test1.cpp test2.cpp
    llvm-link -o test.bc1 test1.o test2.o 
    opt test.bc1 -o test.bc2 -std-compile-opts
    
    llc -filetype=obj test.bc2 -o test.o
    clang++ test.o
    

    This produces a working a.out file.

    It seems that llc is needed to convert from bitcode to machine code which can then be processed by clang as it normally would.

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

Sidebar

Related Questions

Summary: I'm trying to get video from IP camera in emgu, I could display
Summary : is there a way to get the unique lines from a file
Summary: I'm trying to write a text string to a column of type varchar(max)
Summary: How should the UIViewController know the size of its UIView instance when initialising
Summary of my question: Does NSURLConnection retain its delegate? Detailed question and scenario: I
Summary On the release of our new tool a div with some advertisement previews
Summary I have been looking at historical Australian Rules outcomes using excel with an
Summary of what im trying to accomplish: I play motorstorm on PS3 and for
Summary: When attempting to use marshalling to pass string data into a C++ DLL
SUMMARY: How to compile in Release mode...I cannot get it to take what I

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.