neovim/contrib
Daiki Noda ac5a6d9ff5
build: fix RelWithDebInfo optimization flags #31802
Problem:
RelWithDebInfo generates redundant flags:

    Compilation: /usr/bin/cc -O2 -g -Og -g

The `CMAKE_C_FLAGS_RELWITHDEBINFO` variable is being modified in a way
that caused duplicate `-Og` and `-g` flags to be added. The resulting
flags were `-O2 -g -Og -g`.

- `-Og` (Optimize for debugging) and `-O2` (Optimize for performance)
  are different optimization levels. We can't use both at once.
- The duplicate `-g` flag is redundant and no effect.

multiple -O flags has no effect for code, just redundant.

> If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

Solution:
Adjust the flags to use the more appropriate `-O2 -g`.

    Compilation: /usr/bin/cc -O2 -g

BEFORE:

```
:verbose version
NVIM v0.11.0-dev-1443+ge00cd1ab40
Build type: RelWithDebInfo
LuaJIT 2.1.1734355927
Compilation: /usr/bin/cc -O2 -g -Og -g -flto -fno-fat-lto-ob
jects -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict
...
```

AFTER:

```
:verbose version
NVIM v0.11.0-dev-e00cd1ab4-dirty
Build type: RelWithDebInfo
LuaJIT 2.1.1734355927
Compilation: /usr/bin/cc -O2 -g -flto -fno-fat-lto-objects -
Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-protot
...
```
2025-01-05 11:28:31 -08:00
..
gdb feat(jobs): jobstart(…,{term=true}), deprecate termopen() #31343 2024-12-19 07:07:04 -08:00
asan.sh build: add ubsan default options 2023-05-15 16:50:58 +02:00
local.mk.example build: fix RelWithDebInfo optimization flags #31802 2025-01-05 11:28:31 -08:00
minimal.lua docs: dev-arch, focusable windows #30510 2024-10-07 08:27:38 -07:00