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

  • Home
  • SEARCH
  • 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 7849747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:37:29+00:00 2026-06-02T18:37:29+00:00

I am working on a project that I had been compiling with LLVM 2.6

  • 0

I am working on a project that I had been compiling with LLVM 2.6 and the llvm-gcc front end. I’m trying to test compiling it with LLVM 3.1 and clang. When I did this I got the following error message about -O5 optimization level:

error: invalid value '5' in '-O5'

However, LLVM 2.6 and llvm-gcc have worked fine with the -O5 flag. I saw the following documentation about the Clang optimization levels:

-O0 -O1 -O2 -Os -O3 -O4
       Specify which optimization level to use.  -O0 means "no optimization": this level compiles the
       fastest and generates the most debuggable code.  -O2 is a moderate level of optimization which
       enables most optimizations.  -Os is like -O2 with extra optimizations to reduce code size.  -O3
       is like -O2, except that it enables optimizations that take longer to perform or that may
       generate larger code (in an attempt to make the program run faster).  On supported platforms, -O4
       enables link-time optimization; object files are stored in the LLVM bitcode file format and whole
       program optimization is done at link time. -O1 is somewhere between -O0 and -O2.

So I’m trying to figure out what the -O5 in the Makefile I’m working with was doing in the first place (I didn’t write the Makefile). Is this something that changed and used to be used with LLVM? Or is it still a useful feature and I just need to activate it in some other way.

Also in case it’s useful the command I’m running that is giving the error is basically:

/bin/clang -g -c -mcmodel=medium -fstrict-aliasing -Wstrict-aliasing -O5 -emit-llvm -fkeep-inline-functions -fno-stack-protector -c -o foo.bc foo.cpp

Also in case it matters I am running on a Linux (Ubuntu 10.04) x86_64 system.

  • 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-02T18:37:30+00:00Added an answer on June 2, 2026 at 6:37 pm

    Gcc treats any -On for n >= 4 as -O3:

    The -O flag will accept any number from
    0-9 but only zero through three are implemented, and I don’t think that
    anyone has any plans to ever implement four through nine any time soon.
    The fact that people use this -O9 idiom is a little disturbing, because
    it implies that they want every conceivable optimization that gcc could
    possibly ever offer, even if it made compilation take weeks for no
    gain.

    Bigger levels should not be used, you has just low quality Makefile.

    So specifying -O9 is a bit of “but this one goes to eleven!”-type nonsense

    So, when gcc compiler is used, you have valid variants of -O: -O0, -O1, -O2, -O3. But driver will convert any -On to -O3 silently.

    LLVM (both clang and llvm-gcc variants of driver) supports only levels up to -O4 (-O4 is just the same as -O3 -flto). So you should not to use -O4 without testing, because lto is slower and possibly can break your program.

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

Sidebar

Related Questions

I've been trying to get WCF security working for my project, and have had
I've been working on a Java project for year. My code had been working
I was working on a WPF project today that had a main nav window
I've been using Rails 2.3.8 for a project that I've been working on, but
I have been working on a project that requires downloading a zipped file off
I've recently been writing some code for a research project that I'm working on,
I am working on a project that has been running for a long period
I have been working on a project which had been split over several servers
I'm working on a project that involves a simple web service, and have had
I have been working on a project that has common bits of functionality, specifically

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.