Documentation link
CHANGELOG
[Compiler]
- Change build system.
In order to get rid of CMake as dependency, a new custom build system was implemented
using 'nob' as the base "library". In fact, it's just a bunch of helper functions
implemented in C, thus whole new build system is implemented in the same language as
the compiler itself. This way we don't need special DSL to handle compilation process.
Use ./build.bat or ./build.sh now.
- Redesign module system.
This version introduces a new module system completely changing the way the import and
symbol visibility works.
The original solution used one big shared global scope for all symbols in the program, thus
no matter where the import was used, all its symbols were public and accessible even
from other (completely unrelated) modules.
With the new system, imported module symbols might be private or even explicitly
namespaced based on the usage. In general, each module (even target assembly) has its
own namespace (module namespace) divided into public and private part. The private part
might be introduced by `#scope_module` directive. All symbols and other modules imported
in the `#scope_module` block are visible only inside the parent module.
By calling the #import directive, all "public" symbols of imported module are implicitly
inserted into the parent scope of the `#import` directive.
As result, one should have to import explicitly all used modules, so for example even
a simple "hello world" application now have to import print module in order to get access
to the print function. However, this way we can be 100% sure about what dependencies each
module require and achieve better module isolation.
- Load directive now loads source units multiple times in case the #load directive appears
in different scope context.
- Remove ModuleImportPolicy.
The import policy (originally used to allow automatic bundling of used modules into the
project local module directory) was removed. In general it was unnecessary complexity in
the build system I've never used. Note that the same behavior can be still achieved by
manual copying of required modules into the custom module directory.
- Remove named scopes (introduced by #scope directive).
Named scopes were completely removed from the language with introduction of a new
module system. This reduced amount of 'using' required for 'std' for example. Imported
modules can be namespaced on "import" side like this:
foo :: #import "std/string";
- Modules injected into the module scope are accessible recursively on use-side.
Modules imported into "public" module scope are accessible from outside when the module
gets imported. This allows creation of module merging bunch of other modules for example.
- Add windows flag --legacy-colors to enable old style of output coloring on Windows.
Compiler by default outputs ANSI color codes for error messages in terminal even on
Windows. To get back old style of coloring use --legacy-colors compiler flag. This option
is available only on Windows.
- Add explicit module namespacing.
- Compiler will report all possible ambiguous symbol in case there is more of them.
- Fix module import and load to not use current working directory implicitly.
- Fix reports of ambiguous symbols coming from module imports in case we have symbols
with the same name in current module.
- Module configuration use comma separators on all platforms.
- Add new examples into 'how-to' showing how to do static and dynamic linking of external
libraries.
- Nob on linux tries to fallback to `llvm-config` in case `llvm-config-X` wasn't found.
- Add LLVM version check on linux.
- Add more search paths for compiler dependencies on linux.
- Add support for character escape code parsing in strings and character literals.
Newly '\0OOO' (octal notation) and '\xHH' (hex notation) can be used to specify ASCII code.
Thus we can now handle things like:
print("\033[34mBlue Text\033[0m\n");
- Compile-time test run when '--run-tests' is used now outputs ANSI colored reports, this
might by disabled by passing '--no-color' argument to the compiler.
- Fix 'blc -init' to produce compilable 'src/main.bl'.
- Generated documentation for structs now contains name of base struct.
- Compiler macOS setup now include search path for system frameworks and library path provided
by brew by default.
Generate new configuration by 'blc --configure'.
- Add --no-finished-report compiler flag to disable printing of final compilation time report.
- Doctor now outputs warnings in examples.
- #base directive now can take any arbitrary expression evaluating to 'type'. So we can do:
get_type :: fn (T: type #comptime) type #comptime {
return T;
}
Foo :: struct #base get_type(s32) {
}
- Change string builtin to be a dynamic array.
- Fix vmdbg causing compilation fail in case it reported error (for example unknown command
was used).
- Fix vmdbg crash in case it tries to print unused variables.
- `debugbreak` now detects if debugger is attached in runtime and does nothing in case it's not.
- Increased maximum error count to 100 by default. This can be still adjusted by `--error-limit`
command line argument or in `BuilderOptions.error_limit`.
- Fix cyclic dependency detection for unresolved symbols.
- Add a new way to handle errors on a function call-side. The catch statement might be used to catch
an error returned by a function. We might implement separate branch invoked only in case an error
appears.
open_file() catch {
print_err($);
};
- Fix defer issues caused by catch statement. Defer was not correctly called in all blocks in
case catch was present. This situation is now covered by tests too.
- Unified lexer error reports with the rest of the compiler reported errors.
- Fixed u64 literal overflow detection.
- Add exponent parsing for f32 and f64. For example `15.2e+3` of `15.2e-3`.
- Add lexer support for octal literals (starting with 0).
- Add new module configuration entries to handle runtime vs compiletime dynamic library
linking explicitly:
`link_runtime: "<LIB1[,LIB2,...]>"` - Dynamic libraries used only in runtime.
`link_comptime: "<LIB1[,LIB2,...]>"` - Dynamic libraries used only in complile time.
- Add `Windows/System32` into default library search path on windows. Run `blc --configure`.
- Fix issues with namespaced types used as enum base types. For example:
Foo :: enum C.int {}
- Add support for LD script linking on linux + resolving of library symlinks.
- Add LLVM_CONFIG option on Linux and masOS to customize path to llvm-config executable. This way
we might point to locally compiled LLVM or any other LLVM location not available by default in
the system.
- Fallback to linking ncurses_g.a in case libtinfo.a was not found on linux.
- Fix various extra modules linking on linux to respect comptime vs runtime linking.
- Add check for unexpected statements after `then`, `else` and `catch` in case the related code
block is implicit. Example:
if true then a :: 10; // This is not possible, variable would be useless.
- Build option `copy_deps` now copy only non-system dependencies.
- rpath is now set for all libraries coming from module dependencies on Linux.
- Extra module dependencies are now dynamically linked on Linux to prevent linking issues and
collisions. This might change in the future.
- Fix "assume macOS" linker warning on Mac (run `blc --configure`).
- Fix endless looping caused by deeper nesting of dependencies in LLVM IR generator.
- Require explicit block in else if branch in case block is used for true branch.
- Fix scope lookup/register race conditions appearing from time to time when private scope
contains loading of other units.
- Add `add_bool_constant` which might be used in build pipeline to define immutable boolean variables
in target assembly global scope. This way the build pipeline might pass configuration flags to the target.
```
exe := add_executable("test");
add_unit(exe, "build_test.bl");
add_bool_constant(exe, "FOO", false);
```
[Modules]
- Add math module.
std/math:
- Add limits for f32 and f64
std/sync:
- Mutex now can be explicitly initialized as recursive or non-recursive.
std/fs:
- Fix invalid file descriptor reported by `copy` function on linux and mac.
- read_entire_file now returns slice `[]u8` instead of dynamic array.
std/test:
- test_run now output ANSI colored reports in case 'ansi_color' argument passed to the
function is 'true'.
build.bl:
- Add link_static_library. This function just formats name of static library based on current
platform and use append_linker_options to adjust linker arguments.
- Add link_framework. For linking of macOS frameworks.
- Add add_framework_path. For adding search path for macOS frameworks.
- Add `get_default_module_dir` function to resolve default location of modules shipped with
the compiler.
std/string:
- Strings are no longer zero terminated. The string type is now only wrapper over dynamic
array with special semantics. In case zero-termination is required `strtoc` function is
supposed to be used to do the conversion.
os/posix/syscall:
- Removed support for arm64-apple-darwin target since `syscall` is deprecated on macos.
os/linux/sys/ptrace:
- Added.
extra/glfw3:
- Upgraded to version 3.4.
extra/sdl3:
- Add incomplete SDL3 binding module.
extra/glm:
- Add `mat4_remove_scale` function.
- Fix scale extraction from mat4.
- Add simple mat3 support.
[Documentation]
- Improved "Libraries" section in documentation.
- Improved documentation of library linking.
- Add more examples into web documentation. Web listed examples now points directly to the
github.
- Fix syntax highlight issues caused by multiline comments in generated documentation.
- Fix warnings in examples.
- Improve error handling documentation.
[Deprecated]
`array_clear` - Use `arr.len = 0` instead.
`pool_release` - Use release_allocator instead.
`pool_reset` - Use reset_allocator instead.
`str_clear` - Use `str.len = 0` instead.
`str_delete` - Use `str_terminate` instead'.
`str_is_empty` - Use `str.len < 1` instead.
`str_is_null_or_empty` - Use `str.len < 1 || str.ptr` instead.
`str_is_null` - Use `str.ptr == null` instead.
`str_new` - Use `str_make` or `str_init` instead.
`ternary` - Use language builtin `if expr then a else b`.
`tstrtoc` - Use `strtoc` instead.