Skip to content

[AIE2P] Enable stack size section for start up code. #504

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

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions libc/startup/baremetal/aie2/crt1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
// (c) Copyright 2024-2025 Advanced Micro Devices, Inc. or its affiliates

extern "C" {
extern int main(int, char **);
void _Exit(int val) {
(void)val;
done();
}
void _Exit(int) { done(); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will now get name mangled. _Exit is a defined libc symbol,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it is inside extern "C"

void _main_init() { _Exit(main(0, nullptr)); }
}
5 changes: 4 additions & 1 deletion libc/startup/baremetal/aie2p/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
# (c) Copyright 2024-2025 Advanced Micro Devices, Inc. or its affiliates

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we are reusing aie2 startup in aie2p (including asm files). They are similar but not the same, so do you think it is better to have a clear separation here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crt1.cc is supposed to be portable. only crt0 contains the arch-dependent stuff of setting up the initial stack pointer and calling _main_init. Perhaps we can move crt1.cc to a 'common' aie directory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can take this up when we finalize code for future archs.

add_startup_object(
crt0
SRC
Expand All @@ -16,4 +17,6 @@ add_startup_object(
crt1
SRC
../aie2/crt1.cc
COMPILE_OPTIONS
-fstack-size-section
)