Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osx flag #14238

Closed
straight-shoota opened this issue Jan 14, 2024 · 4 comments · Fixed by #14243
Closed

osx flag #14238

straight-shoota opened this issue Jan 14, 2024 · 4 comments · Fixed by #14243

Comments

@straight-shoota
Copy link
Member

straight-shoota commented Jan 14, 2024

While making sure all flags are properly documented (crystal-lang/crystal-book#734), I found a dubious osx compiler flag used in debug codegen:

elsif @program.has_flag?("osx") || @program.has_flag?("android")

This flag is never implicitly set anywhere by the compiler. For MacOS we're using the flag darwin. So this can only work if -Dosx is passed to the compiler explicitly via command line argument. This seems a bit odd.

The flag was originally introduced in #3439. At that time the implicit OS flag was also darwin so it should've never had any implicit effect.
I'm not sure if the odd naming is intentional, but probably not?

Either way, I don't think it's used anywhere, so it might be fine to remove it?
If still necessary for something, as an explicit flag it should have a more descriptive name.

@ysbaddaden Do you have any recollection on this?

@ysbaddaden
Copy link
Contributor

Looking at git blame, this dates from #3439 that added support for LLVM 3.9. It was meant to keep DWARF v2 on macOS for some reason. I was probably following Rust (hence the wrong flag), but it was never limited in practice, so I guess it's safe to drop.

Looking at Rust, they're now using DWARF v4 by default but Android, DragonflyBSD, FreeBSD, NetBSD (v2) and AIX (v3). I found a reference to clang that says macOS 10.11 and iOS9 started supporting v4 (older versions v2 only).

Searching for GetDefaultDwarfVersion() in current clang, they use v4 for Android and a bunch other targets, but v2 for OpenBSD and CUDA, and the rest is by default (I can't find which version).

So we can drop both flags.

@ysbaddaden
Copy link
Contributor

It might be interesting to eventually introduce a per target variable + maybe a compilation variable.

@straight-shoota
Copy link
Member Author

What do you mean by "a per target variable" ?

@ysbaddaden
Copy link
Contributor

ysbaddaden commented Jan 15, 2024

Hum, something we don't have in Crystal: a centralized definition per target triple. For example having a dwarf_version variable with a default value that can be overridden by each target.

Each of clang and rust have a dwarf version variable that can be overridden by each target or toolchain (darwin, linux, linux+android, risc, ...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants