Skip to content

Use /O2 instead of /Ox option for MSVC #30

@ghost

Description

In MSVC, /Ox optimization is used by default.

Compared with /Ox, /O2 has these two additional options:

  • /GF: eliminates duplicate strings
  • /Gy: does function level linking

A stackoverflow question, it has some doc links:
https://stackoverflow.com/questions/5063334/what-is-the-difference-between-the-ox-and-o2-compiler-options

I tested a CPython module pyzstd, adding /GF reduced the .pyd file size from 642 KB to 641 KB, further adding /Gy reduced to 466 KB (!). It seems no performance loss.

A CPython issue about this:
https://bugs.python.org/issue37794

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions