Skip to content

Commit

Permalink
Merge branch 'mr/zynqmp-support-libunwind' into 'master'
Browse files Browse the repository at this point in the history
Use libunwind for exception handling with GNAT-LLVM on ZynqMP

See merge request eng/toolchain/bb-runtimes!73
  • Loading branch information
sebastianpoeplau committed Mar 5, 2024
2 parents bc4783d + eb26a9d commit a4c18c4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions aarch64/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BSP support for ARM64
from support import Compiler, target_compiler
from support import using_llvm_compiler
from support.bsp_sources.archsupport import ArchSupport
from support.bsp_sources.target import DFBBTarget

Expand Down Expand Up @@ -117,7 +117,7 @@ def system_ads(self):

# GNAT-LLVM can't build the embedded Morello runtime yet, so we exclude it for
# the time being.
if target_compiler() != Compiler.gnat_llvm:
if using_llvm_compiler():
result["embedded"] = "system-xi-arm-nxstack-embedded.ads"

return result
Expand Down
12 changes: 11 additions & 1 deletion aarch64/zynqmp/common.ld
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ SECTIONS
__eh_frame_hdr = .;
*(.eh_frame_hdr)
} > REGION_CODE
.eh_frame : { KEEP (*(.eh_frame)) } > REGION_CODE

__eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0;
__eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0;

.eh_frame :
{
__eh_frame_start = .;
KEEP (*(.eh_frame))
__eh_frame_end = .;
} > REGION_CODE

.gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } > REGION_CODE

. = ALIGN(0x1000);
Expand Down
4 changes: 4 additions & 0 deletions support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ def set_target_compiler(comp):

def target_compiler():
return _TARGET_COMPILER


def using_llvm_compiler():
return target_compiler() == Compiler.gnat_llvm
10 changes: 3 additions & 7 deletions support/bsp_sources/installer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from support import readfile, getdatafilepath, Compiler, target_compiler
from support import readfile, getdatafilepath, using_llvm_compiler
from support.bsp_sources.target import Target
from support.files_holder import _copy

Expand Down Expand Up @@ -147,15 +147,11 @@ def _find_rts_sources(self, destination, descriptor):
break
if ret is None:
# gprls did not work, try to find out manually the proper location
compiler_name_pattern = (
"%s-llvm-gcc" if target_compiler() == Compiler.gnat_llvm else "%s-gcc"
)
compiler_name_pattern = "%s-llvm-gcc" if using_llvm_compiler() else "%s-gcc"
compiler = shutil.which(compiler_name_pattern % self.tgt.target)
if compiler is not None:
compiler_root = os.path.dirname(os.path.dirname(compiler))
lib_dir = (
"gnat-llvm" if target_compiler() == Compiler.gnat_llvm else "gnat"
)
lib_dir = "gnat-llvm" if using_llvm_compiler() else "gnat"
tentative = os.path.join(
compiler_root, self.tgt.target, "lib", lib_dir, rts_json_file
)
Expand Down
8 changes: 5 additions & 3 deletions support/bsp_sources/target.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
import sys

from support import readfile, is_string, Compiler, target_compiler
from support import readfile, is_string, using_llvm_compiler
from support.files_holder import FilesHolder
from support.bsp_sources.archsupport import ArchSupport
from support.rts_sources.profiles import RTSProfiles
Expand Down Expand Up @@ -176,7 +176,7 @@ def __init__(self):
"c_flags": ["-DIN_RTS", "-Dinhibit_libc", "-DLIGHT_RUNTIME"],
}
# GNAT-LLVM doesn't support -fcallgraph-info
if target_compiler() != Compiler.gnat_llvm:
if using_llvm_compiler():
self.build_flags["common_flags"].append("-fcallgraph-info=su,da")

# Add the following compiler switches to runtime.xml for all targets:
Expand All @@ -187,7 +187,7 @@ def __init__(self):
# a hidden runtime dependency that is considered undesirable by many
# of our customers. strlen is particularly problematic, as its not
# provided in our light and light-tasking runtimes.
if target_compiler() == Compiler.gnat:
if using_llvm_compiler():
self.global_compiler_switches = ("-fno-tree-loop-distribute-patterns",)
else:
self.global_compiler_switches = ()
Expand Down Expand Up @@ -372,6 +372,8 @@ def dump_runtime_xml(self, rts_name, rts):
blank
+ '"-nostartfiles", "-nolibc", '
+ '"-Wl,--start-group,-lgnarl,-lgnat,-lc,-lgcc,-lgcc_eh,--end-group",'
if using_llvm_compiler()
else '"-Wl,--start-group,-lgnarl,-lgnat,-lc,-lunwind,--end-group",'
)

# Add the user script path first, so that they have precedence
Expand Down
3 changes: 3 additions & 0 deletions support/rts_sources/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# BSP to actually create a runtime project.

import sys
from support import using_llvm_compiler
from support.rts_sources import Rule
from support.rts_sources.sources import all_scenarios, sources

Expand Down Expand Up @@ -61,6 +62,8 @@ def light_scenarios(self, profile="light"):
"""Returns the list of directories contained in a base Light runtime"""
ret = {}
ret["RTS_Profile"] = profile
ret["Compiler_Backend"] = "llvm" if using_llvm_compiler() else "gcc"

ret["Add_Arith64"] = "yes"
ret["Add_Case_Util:yes"] = "yes"
ret["Add_Exponent_Float"] = "yes"
Expand Down
10 changes: 9 additions & 1 deletion support/rts_sources/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
all_scenarios = {
# Main profile
"RTS_Profile": ["light", "light-tasking", "embedded", "cert"],
"Compiler_Backend": ["gcc", "llvm"],
# Runtime RTP support
"Is_RTP": ["no", "yes"],
# CPU architecture
Expand Down Expand Up @@ -1523,8 +1524,15 @@
"srcs": [
"libgnat/s-excmac__gcc.ads",
"libgnat/s-excmac__gcc.adb",
"libgcc/unwind-dw2-fde.h",
],
},
"full/zcx-dw2-gcc": {
"conditions": [
"RTS_Profile:embedded",
"CPU_Family:!arm",
"Compiler_Backend:gcc",
],
"srcs": ["libgcc/unwind-dw2-fde.h"],
"bb_srcs": ["hie/unwind-dw2-fde-bb.c"],
},
"full/zcx-aarch64": {
Expand Down

0 comments on commit a4c18c4

Please sign in to comment.