So far, the first comment found was marked as package docs, which
meant that for the following code, the TODO comment would be assigned
to the package declaration instead of the comment directly preceding
the package declaration.
// TODO: drop after finished with refactoring
#+ feature using-stmt
// Package foo implements this and that.
package foo
We had the recommended form of file tags for long enough. Also there
were some issues with the deprecated file tags - they were ignored if
the appeared after recommended file tags, and could possibly show up
in package docs.
To avoid creating a procedure literal from a procedure type and a
following block statement, one can insert a semicolon or an empty line
between the two:
// procedure literals
p1 :: proc() {…}
p2 :: proc()
{…}
// procedure type followed by a block statement
p3 :: proc()
{…}
The empty line as a separator did not work if the procedure type had a
diverging result:
// all of these are procedure literals
p4 :: proc() -> ! {…}
p5 :: proc() -> !
{…}
p6 :: proc() -> !
{…}
The least annoying fix I came up with is to insert implicit semicolon
after the "not" token. I only needed to make sure that the inserted
implicit semicolon is being skipped when the "not" token is a part of
unary expression to avoid breaking an oddly-formatted code like:
b := get_some_bool()
if !
b {…}
One small side-effect of this change is that in code like below:
Proc_Type :: proc() -> !
// Some comment
Some_Other_Type :: enum byte {…}
The "// Some comment" is not associated with "Proc_Type" anymore. In
Odin's standard library this only happens in one place, in
`base/runtime/core.odin`:
Assertion_Failure_Proc :: #type proc(prefix, message: string, loc: Source_Code_Location) -> !
// Allocation Stuff
Allocator_Mode :: enum byte {
Alloc,
…,
}
```
-did-you-mean-limit:<integer>
Sets the maximum number of suggestions the compiler provides.
Must be an integer >0.
If not set, the default limit is 10.
```
e.g. with a limit of 5
```
W:/Scratch/main.odin(44:7) Error: Undeclared name 'B1' for type 'E'
e = .B1
^^
Suggestion: Did you mean?
A23
A02
A19
A20
A21
... and 25 more ...
```
This allows you to pipe the output to a file and have a working graph without any editing.
(Provided you don't also use additional -flags like `-show-timings`.)
On Windows with LTO, required procedures with external linkage need to
be added to @llvm.used to survive linker-level dead code elimination.
LLVM may generate implicit calls to runtime builtins (e.g., __extendhfsf2
for f16 conversions) during instruction lowering, after the IR is
finalized. Without @llvm.used, the linker discards these procedures
before the implicit calls are generated.
This adds required procedures to @llvm.used at creation time. The fix
is Windows-specific; other platforms handle this correctly.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
lld-link doesn't recognize /lldltojobs:N as a standalone flag and
treats it as a file path. Use /opt:lldltojobs=N instead.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
With ThinLTO, the linker runs sanitizer passes at link time via
-fsanitize= flags, where it has whole-program visibility. Running
them at bitcode emission too double-instruments every module,
producing hundreds of "Redundant instrumentation detected" warnings.
Per-function sanitize/no_sanitize attributes are preserved in the
bitcode and respected by the linker's pass.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add -lto:thin and -lto:thin-files CLI flags with validation
- Emit LLVM bitcode (.bc) instead of object files when LTO is enabled
- Pass -flto=thin and -flto-jobs to clang/lld linkers
- Guard linkage corrections to skip declarations without definitions
(required for LTO where declarations appear across modules)
- Allow module-per-file with LTO even at higher optimization levels
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
If no `-minimum-os-version` is given, ignore the `override-module`
warnings. The user not using, `-minimum-os-version` opts you into linker
warnings about target versions.
If a `-minimum-os-version` is provided, normalize it to a full version
`11` to `11.0.0` for example. The linker seems to want that when doing
LTO.