This is wrong because it turned into a double reference type becasuse this
bug was consistent bugs were not picked up but this is not correct. We now
reuse our type inference infrastructure to solve the parameters instead.
Philip Herron [Fri, 10 Mar 2023 18:13:01 +0000 (18:13 +0000)]
gccrs: tyty get rid of useless virtuals
This removes can_substitute and contains_type_parameters which were
confusing interfaces to act as a proxy to the SubstitionRef types. This
replaces them with a single base implementation which is much easier to
debug and follow.
Tage Johansson [Sat, 4 Mar 2023 18:43:02 +0000 (19:43 +0100)]
gccrs: Add all rust keywords (except priv) to the follow-set of `:vis` when parsing macro rules
Previously, the following macro rules were rejected by gccrs:
```Rust
macro_rules! {
($v:vis <KEY_WORD>) => { ... };
}
```
This PR fixes so the above code is accepted by the compiler for all key words like `async` or `unsafe`.
The only exception is the keyword `priv` which is not allowed.
See [this page](https://doc.rust-lang.org/reference/macro-ambiguity.html) for reference. Especially the following excerpt:
> FOLLOW(vis) = {,l any keyword or identifier except a non-raw priv; any token that can begin a type; ident, ty, and path nonterminals}.
Fixes #1060
gcc/rust/ChangeLog:
* parse/rust-parse.cc: fix follow-sets
gcc/testsuite/ChangeLog:
* rust/compile/macro47.rs: Test that :vis can be followed by some keywords
* rust/compile/macro48.rs: Test that :vis cannot be followed by the keyword priv
Signed-off-by: Tage Johansson <frans.tage@gmail.com>
Mahmoud Mohamed [Mon, 13 Mar 2023 14:18:11 +0000 (17:18 +0300)]
gccrs: resolve: Handle multiple bindings to the same identifier
https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/late.rs#L3168
This commit follows rustc's implementation of handling multiple bindings
to the same identifier in parameters.
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit) :declare and
pass bindings to PatternDeclaration::go.
(ResolveExpr::resolve_closure_param): Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise.
(ResolveItem::visit): Likewise.
* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): Likewise.
(PatternDeclaration::visit): check for previous identifier bindings
before inserting the new one.
* resolve/rust-ast-resolve-pattern.h (enum PatternBoundCtx): New enum.
* resolve/rust-ast-resolve-stmt.h: pass bindings to PatterDeclaration::go.
Owen Avery [Tue, 14 Mar 2023 22:52:50 +0000 (18:52 -0400)]
gccrs: Convert structs to classes
gcc/rust/ChangeLog:
* hir/tree/rust-hir-full-decls.h
(struct GenericArgsBinding): Convert to class.
(class GenericArgsBinding): Convert from struct.
(struct TypePathFunction): See above.
(class TypePathFunction): See above.
(struct QualifiedPathType): See above.
(class QualifiedPathType): See above.
* ast/rust-ast-full-decls.h
(struct WhereClause): See above.
(class WhereClause): See above.
(struct SelfParam): See above.
(class SelfParam): See above.
(struct FunctionQualifiers): See above.
(class FunctionQualifiers): See above.
(struct FunctionParam): See above.
(class FunctionParam): See above.
(struct StructField): See above.
(class StructField): See above.
(struct TupleField): See above.
(class TupleField): See above.
(struct TraitFunctionDecl): See above.
(class TraitFunctionDecl): See above.
(struct TraitMethodDecl): See above.
(class TraitMethodDecl): See above.
(struct NamedFunctionParam): See above.
(class NamedFunctionParam): See above.
* hir/tree/rust-hir-path.h
(struct GenericArgsBinding): See above.
(class GenericArgsBinding): See above.
(struct TypePathFunction): See above.
(class TypePathFunction): See above.
(struct QualifiedPathType): See above.
(class QualifiedPathType): See above.
* ast/rust-item.h
(struct WhereClause): See above.
(class WhereClause): See above.
(struct SelfParam): See above.
(class SelfParam): See above.
(struct FunctionQualifiers): See above.
(class FunctionQualifiers): See above.
(struct FunctionParam): See above.
(class FunctionParam): See above.
(struct StructField): See above.
(class StructField): See above.
(struct TupleField): See above.
(class TupleField): See above.
(struct TraitFunctionDecl): See above.
(class TraitFunctionDecl): See above.
(struct TraitMethodDecl): See above.
(class TraitMethodDecl): See above.
(struct NamedFunctionParam): See above.
(class NamedFunctionParam): See above.
Arthur Cohen [Wed, 1 Mar 2023 11:35:18 +0000 (12:35 +0100)]
gccrs: hir: Add ExportedMacro node and handling.
This HIR node represents macros which should be exported into the final
Rust metadata files. Because our metadata exporter operates on the HIR,
while macros are inherently tied to the AST, we need a way to propagate
exported macros up until the metadata export pass on the HIR. Hence the
existence of this class, whose sole purpose is to keep enough information
for the metadata exporter to retrieve the original AST::MacroRulesDefinition.
Handling for actually exporting these macros will come later.
Mahmoud Mohamed [Tue, 7 Mar 2023 23:57:24 +0000 (02:57 +0300)]
gccrs: hir: Provide basic handling for ReferencePattern in function parameter
Added an implementation for
`CompilePatternBindings::visit (HIR::ReferencePattern)` where we
dereference the initial expression and recurse.
Added an implementation for
`CompilePatternBindings::visit (HIR::IdentifierPattern)` as well since it's
the simplest base case.
In addition to this, a small refactor for the shared code in
`StructPattern` and `TupleStructPattern` visits was added as a helper
function called `create_tmp_param_var`.
gcc/rust/ChangeLog:
* backend/rust-compile-fnparam.cc (CompileFnParam::visit):
Added visit implementation for ReferencePattern.
(CompileFnParam::create_tmp_param_var):
Refactored duplicated code into a helper function.
* backend/rust-compile-fnparam.h: Added visit implementation for
ReferencePattern.
* backend/rust-compile-pattern.cc (CompilePatternBindings::visit):
Added visit implementation for ReferencePattern and
IdentifierPattern.
* backend/rust-compile-pattern.h: Added visit implementation for
ReferencePattern and IdentifierPattern.
gcc/testsuite/ChangeLog:
* rust/compile/ref_pattern_fn_param.rs: Moved to...
* rust/compile/ref_pattern_fn_param1.rs: ...here.
* rust/compile/ref_pattern_fn_param2.rs: New test.
* rust/execute/torture/ref-pattern1.rs: New test.
Arthur Cohen [Thu, 2 Mar 2023 15:56:33 +0000 (16:56 +0100)]
gccrs: enr: Fetch module items during early name resolution
This is important as public macros can be present in other modules,
which would otherwise not be loaded until the expansion phase
happening right after the early name resolution.
Jakub Dupak [Sat, 11 Mar 2023 19:36:11 +0000 (20:36 +0100)]
gccrs: hir: Unify indentation approach with ast
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Indent::Indent): Move to separate file.
(operator<<): Move to separate file.
(Indent::increment): Move to separate file.
(Indent::decrement): Move to separate file.
* ast/rust-ast-dump.h (class Indent): Move to separate file.
* hir/rust-hir-dump.cc (Dump::Dump): Use new indentation object.
(Dump::go): Use new indentation object.
(Dump::visit): Use new indention object.
* hir/rust-hir-dump.h: Use new indentation object.
* util/rust-dump.h: New file. Moved Indentation from rust-ast-dump.cc
Marc Poulhiès [Sat, 17 Dec 2022 15:23:05 +0000 (16:23 +0100)]
gccrs: fix some clang warnings
This fixes some extra warnings reported by clang.
gcc/rust/ChangeLog:
PR rust/108111
* ast/rust-ast-full-decls.h (StructPatternElements): Declare as a
class.
* ast/rust-item.h (EnumItem): Mark several method as being
overrides.
* ast/rust-pattern.h (StructPattern::get_locus): Add override.
* lex/rust-lex.h (BufferInputSource): Use reference_wrapper
instead of bare reference.
(TokenSource::get): Add method to implement the reference_wrapper
interface.
* typecheck/rust-tyty.h (TypeBoundPredicate): Add empty dtor.
* util/rust-buffered-queue.h (peek): Source token stream is now
using a reference_wrapper, use .get()
vincent [Tue, 7 Mar 2023 20:32:04 +0000 (20:32 +0000)]
gccrs: hir: add a helper function for visit
This commit adds a helper function for TypeCheckPattern::visit
(HIR::RangePattern &pattern) to remove redundancy
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): rewrite part code to helper function
(TypeCheckPattern::typecheck_range_pattern_bound): helper function
* typecheck/rust-hir-type-check-pattern.h
(TypeCheckPattern::typecheck_range_pattern_bound):
change the parameter of the function
Signed-off-by: Jiakun Fan <jfan30@u.rochester.edu>
Owen Avery [Tue, 7 Mar 2023 18:37:08 +0000 (13:37 -0500)]
gccrs: Add coherence related lang_items
gcc/rust/ChangeLog:
* util/rust-lang-item.h
(RustLangItem::ItemType): New enumerators.
(RustLangItem::Parse): Parse new enumerators.
(RustLangItem::ToString): Handle new enumerators.
* rust/compile/stringify.rs: Add a basic test with some text.
* rust/execute/torture/builtin_macro_stringify.rs: Verify the
text is left as is without any other macro expansion.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
Add length checking for tuple patterns.
(TypeCheckPattern::emit_pattern_size_error): New function.
* typecheck/rust-hir-type-check-pattern.h: New function
emit_pattern_size_error.
Philip Herron [Fri, 3 Mar 2023 18:17:50 +0000 (18:17 +0000)]
gccrs: make predicate bounds overwrite-able
When compiling types especially when using queries it needs to be
permissive and allow them to be overwritten and a predicate might have one
set of details in one senario and a new one with the same id later on but
with different types.
Fixes #1524
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
Philip Herron [Fri, 3 Mar 2023 18:01:01 +0000 (18:01 +0000)]
gccrs: Fix name-resolution to be permissive and carry on
There are a few edge cases when resolving TypePaths that we cannot fully
resolve to an explicit node_id and this is expected. So for example
<A as B>::foo
A and B are simple Type paths and thats 100% but the segment foo cannot be
100% resolved to an explicit node id as this requires type-resolution to
find the correct path. So when we have complex paths such as:
<<A as B>::foo as C>
The ::foo part will return UNKNOWN_NODEId and we return early and think its
a failure case but its not necessarily a failure but we need to make sure
to name resolve C so when we do type-resolution we can resolve C properly.
Addresses #1524
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
Philip Herron [Wed, 1 Mar 2023 22:09:47 +0000 (22:09 +0000)]
gccrs: Fix missing move and copy constructors missing the associated-path
Addresses #1524
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* ast/rust-ast.cc (QualifiedPathInType::as_string): add missing to string
* ast/rust-path.h: add missing copy+move constructors and assignment overloads
* hir/tree/rust-hir-path.h: likewise
* hir/tree/rust-hir.cc (QualifiedPathInType::as_string): add missing to string
gcc/testsuite/ChangeLog:
* rust/compile/parse_associated_type_as_generic_arg.rs: it now works without -fsyntax-only
* rust/compile/parse_associated_type_as_generic_arg2.rs: likewise
Philip Herron [Fri, 3 Mar 2023 16:12:46 +0000 (16:12 +0000)]
gccrs: destructure parameter names.
When we have complex generic code you can end up with situations where we
compile types:
Maybe<<S as Foo>::A>
Into
Maybe<<placeholder:<Projection=::()>>>
This calls destructure to cleanup the naming here and avoid making non
canonical TREE_TYPES hitting the verify_gimple code triggering non-trival
constructors.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
Philip Herron [Fri, 3 Mar 2023 18:42:21 +0000 (18:42 +0000)]
gccrs: Take advantage of our new unify_and to inject inference
Wen computing higher ranked trait bounds where there are multiple type
params and ones which are not bound entirely on the impl-type we need
to inject inference variables as required to compute the types. The
inference variables we inject are missing the callbacks that we can compute
the bounds properly so this is the first part of the fix.
Addresses #1893
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-resolve.cc: use unify_and infer
While let expr return unit but are valid construct in rust, they should
therefore be included in the parsing code. Also add a new test to check
parsing of while let expressions.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_while_let_loop_expr):
Prevent hard error on token skip.
(Parser::null_denotation): Fix parser for while let expressions.
Philip Herron [Wed, 1 Mar 2023 12:43:56 +0000 (12:43 +0000)]
gccrs: add uninit intrinsic
Following an investigation from rustc and discussions on zulip the
recommendation was that for uninit we memset to 0x01 which is less likely
to be a null ptr but still an invalid reference.
Fixes #1899
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* backend/rust-builtins.cc (BuiltinsContext::setup): add memset builtin to the map
* backend/rust-compile-intrinsic.cc (uninit_handler): implement uninit intrinsic
gcc/testsuite/ChangeLog:
* rust/compile/torture/uninit-intrinsic-1.rs: New test.
Abdul Rafey [Mon, 27 Feb 2023 12:01:31 +0000 (17:31 +0530)]
gccrs: added support for printing HIR dump of functions, statements, arithematic/logical expressions and literals.
gcc/rust/ChangeLog:
* hir/rust-hir-dump.cc (Dump::go): support inner attrs, crate items and node mappings
(Dump::visit): support functions, arith/logical exprs, let stmts and literals
Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
Fix if let parsing in null_notation function. This problem was due to
the current token already being passed in the function parameters and
already out of the buffered queue. Hence why the peeked token was let
and not if.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::null_denotation): Fix if let
parsing.
Philip Herron [Wed, 1 Mar 2023 11:42:36 +0000 (11:42 +0000)]
gccrs: add {add,sub,mul}_with_overflow intrinsics
Fixes #1898
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* backend/rust-compile-intrinsic.cc (op_with_overflow_inner): wraps op_with_overflow
(std::function<tree): likewise
(op_with_overflow): generate the intrinsic based on the tree_code op
Philip Herron [Mon, 27 Feb 2023 19:16:00 +0000 (19:16 +0000)]
gccrs: Fix method resolution to use TryCoerce
Rust allows us to call generic pointer methods on pointers so in non
generic contexts the old code using the bad can_eq interface couldn't
handle this case. So taking advantage of our new unify_and interface to try
and infer when required we can start using our TryCoerce interface to reuse
existing code to assemble possible candidates more acurately using the
existing coercion rules.
Fixes #1901 #878
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* typecheck/rust-coercion.cc (TypeCoercionRules::Coerce): Add new try_flag
(TypeCoercionRules::TypeCoercionRules): set new try flag
(TypeCoercionRules::do_coercion): default to a final unify_and in the else case
(TypeCoercionRules::coerce_unsafe_ptr): cannot coerce to a ptr from ref during autoderef
(TypeCoercionRules::coerce_borrowed_pointer): respect coerceable mutability
* typecheck/rust-coercion.h: update header
* typecheck/rust-hir-dot-operator.cc (MethodResolver::select): use new TryCoerce interface
(MethodResolver::append_adjustments): ensure we maintain adjustment mappings
* typecheck/rust-hir-dot-operator.h: add new method append_adjustments
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): extra logging
Philip Herron [Mon, 27 Feb 2023 17:39:09 +0000 (17:39 +0000)]
gccrs: bug-fix implicit inference checks
When generating implicit inference variables we can miss cases where the
other side might be another inference variable too but it runs the risk of
generating unending inference cycles needing more info but if they other
side is a non general inference variables like <integer> or <float> this
is safe to do so and allows us to infer mroe cases.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
Philip Herron [Sun, 26 Feb 2023 22:08:26 +0000 (22:08 +0000)]
gccrs: Generic pointers are coerceable
This is a complex type-system change where it begins out journey to get
rid of our can_eq interface. Rust allows:
let x:*mut T
let y = x as *mut u8;
Which requires us to consider find a way to infer what T should be so as
to keep unify happy. This means we need to introduce a new unify_and
interface where we can optionally inject inference variables as well as
only commit the inference variable joins when they are sucsessful.
So for this case we can then inject an implicit inference variables for T
that can unify against u8 to make this a valid type-resolution.
Fixes #1930
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (CompileExpr::resolve_method_address): update to new inteface
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsafe_ptr): likewise
(TypeCoercionRules::coerce_borrowed_pointer): likewise
* typecheck/rust-hir-type-check.h: likewise
* typecheck/rust-type-util.cc (unify_site_and): new interface to allow for infer and commit
* typecheck/rust-type-util.h (unify_site_and): likewise
* typecheck/rust-typecheck-context.cc (TypeCheckContext::clear_type): new interface
* typecheck/rust-unify.cc (UnifyRules::UnifyRules): update
(UnifyRules::Resolve): new optional flags for commit and infer
(UnifyRules::go): likewise
(UnifyRules::expect_adt): refactor to use new interface
(UnifyRules::expect_reference): likewise
(UnifyRules::expect_pointer): likewise
(UnifyRules::expect_array): likewise
(UnifyRules::expect_slice): likewise
(UnifyRules::expect_fndef): likewise
(UnifyRules::expect_fnptr): likewise
(UnifyRules::expect_tuple): likewise
(UnifyRules::expect_closure): likewise
* typecheck/rust-unify.h: refactor interface
Add the code to parse type item declaration within an extern block.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_external_type_item):
Add function to parser an external type item.
(Parser::parse_external_item):
Add identification and parsing for external type items.
* parse/rust-parse.h:
Add parser_external_type_item prototype.
Arthur Cohen [Thu, 23 Feb 2023 14:11:04 +0000 (15:11 +0100)]
gccrs: parser: Parse `default` impl Functions and Methods
gcc/rust/ChangeLog:
* ast/rust-item.h (class Method): Add `is_default` field.
(class Function): Likewise.
* parse/rust-parse-impl.h (Parser::parse_item): Add nice error when
parsing `default` outside of an `impl` block
(Parser::parse_trait_impl_item): Allow parsing functions
or methods when seeing `default`.
gcc/testsuite/ChangeLog:
* rust/compile/parse_invalid_specialization.rs: New test.
* rust/compile/parse_specialization.rs: New test.
* rust/compile/default_not_a_kw.rs: New test.
Arthur Cohen [Wed, 15 Feb 2023 15:53:41 +0000 (16:53 +0100)]
gccrs: parser: Add parsing of auto traits
This adds enough handling to start parsing `auto` traits but not handle
them in the AST, lowering phase or HIR yet.
The feature is named `optin_builtin_traits` in Rust 1.49 but changes to
`auto_traits` later down the line. So we'll need to take care of this later
on.
Finally, this also changes the way the lexer detects if a string is a
keyword or not. We relied on a call to `std::lower_bound` to figure
out if a string was contained in an array or not, and this ended up
causing issues when adding new keywords. We can instead switch to a
simple hashmap and search for the key. The code *might* be less
optimized (unsure) but it is definitely simpler and easier to read.
Fixes #1814
gcc/rust/ChangeLog:
* ast/rust-item.h (class Trait): Add `has_auto` field.
* checks/errors/rust-feature.cc: Add handling for `feature(optin_builtin_traits)`
* checks/errors/rust-feature.h: Likewise.
* lex/rust-lex.cc: Fix keyword classification using hashmap.
* lex/rust-token.h: Add `auto` keyword token.
* parse/rust-parse-impl.h (Parser::parse_vis_item): Parse auto traits
on `auto` keyword.
gcc/testsuite/ChangeLog:
* rust/compile/auto_trait_invalid.rs: New test.
* rust/compile/auto_trait_valid.rs: New test.
Arthur Cohen [Thu, 16 Feb 2023 12:53:22 +0000 (13:53 +0100)]
gccrs: parser: Allow parsing of qualified type path as nested generic argument
Let's take the example of lexing `Option<<T as Iterator>::Item>` and look
at the first few tokens. Originally, `Option<<T` was lexed as 3 tokens:
* IDENTIFIER(Option)
* LEFT_SHIFT
* IDENTIFIER(T)
The parser did not allow a list of generic arguments to start with a left
shift, and rejected the above type. We are now splitting the left shift
into two left angles, as this allows complex generic arguments and overall
makes sense parsing wise. Thus, the above list becomes:
and `<T as Iterator>` is properly parsed as a qualified path.
Fixes #1815
Fixed #1809
Addresses #1524
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_path_generic_args): Split leading
`LEFT_SHIFT` token into two `LEFT_ANGLE` tokens when parsing generic arguments.
(Parser::parse_type_path_segment): Allow `LEFT_ANGLE` as starting token for
parsing generic arguments.
gcc/testsuite/ChangeLog:
* rust/compile/parse_associated_type_as_generic_arg.rs: New test.
* rust/compile/parse_associated_type_as_generic_arg2.rs: New test.
* rust/compile/path_as_generic_arg.rs: New test.
* rust/compile/nested_generic.rs: New test.
Wilco Dijkstra [Tue, 16 Jan 2024 16:27:02 +0000 (16:27 +0000)]
AArch64: Reassociate CONST in address expressions
GCC tends to optimistically create CONST of globals with an immediate offset.
However it is almost always better to CSE addresses of globals and add immediate
offsets separately (the offset could be merged later in single-use cases).
Splitting CONST expressions with an index in aarch64_legitimize_address fixes
part of PR112573.
Daniel Cederman [Fri, 8 Dec 2023 08:49:12 +0000 (09:49 +0100)]
sparc: Char arrays are 64-bit aligned on SPARC
pr88077 fails on SPARC since char HeaderStr[1] in pr88077_1.c and
long HeaderStr in pr88077_0.c differs in alignment.
Warning printed by Binutils ld:
warning: alignment 4 of normal symbol `HeaderStr' in c_lto_pr88077_0.o is
smaller than 8 used by the common definition in c_lto_pr88077_1.o
gcc/testsuite/ChangeLog:
* gcc.dg/lto/pr88077_0.c: Change type to match alignment for SPARC
Daniel Cederman [Thu, 4 Jan 2024 13:56:06 +0000 (14:56 +0100)]
sparc: Add errata workaround to membar patterns
LEON now uses the standard V8 membar patterns that contains an ldstub
instruction. This instruction needs to be aligned properly when the
GR712RC errata workaround is enabled.
gcc/ChangeLog:
* config/sparc/sparc.cc (atomic_insn_for_leon3_p): Treat membar_storeload as atomic
* config/sparc/sync.md (membar_storeload): Turn into named insn
and add GR712RC errata workaround.
(membar_v8): Add GR712RC errata workaround.
Andreas Larsson [Mon, 16 Jan 2023 14:43:24 +0000 (15:43 +0100)]
sparc: Revert membar optimization that is not suitable for LEON5
LEON5 has a deeper write-buffer and hence stb is not enough to flush a
write out. For compatibility, use the default V8 approach for both
LEON3 and LEON5.