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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:13:58+00:00 2026-06-05T01:13:58+00:00

I understand that setup.py uses the same CFLAGS that were used to build Python.

  • 0

I understand that setup.py uses the same CFLAGS that were used to build Python. I have a single C extension of ours that is segfaulting. I need to build it without -O2 because -O2 is optimizing out some values and code so that the core files are not sufficient to pin down the problem.

I just need to modify setup.py so that -O2 is not used.

I’ve read distutils documentation, in particular distutils.ccompiler and distutils.unixccompiler and see how to add flags and libs and includes, but not how to modify the default GCC flags.

Specifically, this is for a legacy product on Python 2.5.1 with a bunch of backports (Fedora 8, yes, I know…). No, I cannot change the OS or Python version and I cannot, without great problems, recompile Python. I just need to build a one off of the C extension for one customer whose environment is the only one segfaulting.

  • 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-05T01:13:59+00:00Added an answer on June 5, 2026 at 1:13 am
    • Prepend CFLAGS="-O0" before you run setup.py:

      % CFLAGS="-O0" python ./setup.py
      

      The -O0 will be appended to CFLAGS while compiling, therefore will override previous -O2 setting.

    • Another way is add -O0 to extra_compile_args in setup.py:

      moduleA = Extension('moduleA', .....,
              include_dirs = ['/usr/include', '/usr/local/include'], 
              extra_compile_args = ["-O0"], 
              )
      
    • If you want to remove all default flags, use:

      % OPT="" python ./setup.py
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that HTML emails need to use really old school layouts - as
I have a SQL Server 2008 database table that uses uniqueidentifier as a primary
I have been having a terrible time trying to compile a python extension -
I am trying to setup a program that uses Java and OpenCL. I am
I understand the need to test a class that has logic (for instance, one
I'm working on a Python package that uses namespace_packages and find_packages() like so in
I have a Java web application that currently uses Log4J for logging. I'd like
I'm trying to make a clean maven setup on some legacy project that uses
So, I understand that it's possible to set up in-app purchases for iPhone apps
I understand that this a very noob problem, but when I try to create

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.