Skip to content

Commit

Permalink
Merge branch 'topic/backport-auto-nvdrive-3841-W518-004' into '3841-W…
Browse files Browse the repository at this point in the history
…518-004'

Backport auto-nvdrive source profile changes to 3841-W518-004

See merge request eng/toolchain/bb-runtimes!143
  • Loading branch information
Aleksandra Pasek committed Nov 26, 2024
2 parents 9ae5f39 + 15c2bfd commit 62ca4f1
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 35 deletions.
19 changes: 12 additions & 7 deletions build_rts.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
from x86_64 import X8664Generic

# native
from native import Aarch64Native, X86Native, X8664Native
from linux import Aarch64Linux, X86Linux, X8664Linux
from windows import X86Windows, X8664Windows

# vx7r2cert
from vx7r2cert import AArch64Vx7r2Cert, ArmVx7r2Cert, \
Expand Down Expand Up @@ -224,12 +225,16 @@ def build_configs(target):
elif target == 'x86_64':
t = X8664Generic()
# native platforms
elif target in ('x86-linux', 'x86-windows'):
t = X86Native()
elif target in ('x86_64-linux', 'x86_64-windows', 'x86_64-windows64'):
t = X8664Native()
elif target in ('aarch64-linux',):
t = Aarch64Native()
elif target == "aarch64-linux":
t = Aarch64Linux()
elif target == "x86-linux":
t = X86Linux()
elif target == "x86_64-linux":
t = X8664Linux()
elif target == "x86-windows":
t = X86Windows()
elif target in ("x86_64-windows", "x86_64-windows64"):
t = X8664Windows()
# vx7r2cert
elif target == "aarch64-vx7r2cert":
t = AArch64Vx7r2Cert()
Expand Down
3 changes: 2 additions & 1 deletion gen_rts_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def main():
'--rts-profile', choices=['light', 'light-tasking', 'embedded', 'cert'],
required=True, help='supported profiles')
parser.add_argument(
'--source-profile', choices=['bb', 'deos', 'pikeos', 'vx7r2cert', 'qnx'],
'--source-profile',
choices=['bb', 'deos', 'linux', 'pikeos', 'vx7r2cert', 'qnx'],
default='bb', help='platform specific source selections')

args = parser.parse_args()
Expand Down
38 changes: 19 additions & 19 deletions native/__init__.py → linux/__init__.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
from support.bsp_sources.target import DFBBTarget


class Native(DFBBTarget):
class Linux(DFBBTarget):
def __init__(self):
super().__init__()
self.add_gnat_sources(
'src/s-macres__native.adb',
'src/s-textio__stdio.adb')

@property
def target(self):
return None
self.add_gnat_sources("src/s-macres__native.adb")
self.add_gnarl_sources("linux/adaint.c")

def has_libc(self, profile):
return True

@property
def name(self):
return self.target

def dump_runtime_xml(self, rts_name, rts):
return ('<?xml version="1.0" ?>\n'
'<gprconfig>\n'
' <configuration>\n'
' </configuration>\n'
'</gprconfig>\n')

def amend_rts(self, rts_profile, cfg):
super().amend_rts(rts_profile, cfg)
@property
def is_legacy_format(self):
return True


class X86Native(Native):
class X86Linux(Linux):
@property
def name(self):
return 'native-x86'
def target(self):
return "x86-linux"

@property
def system_ads(self):
return {'light': 'system-xi-x86.ads'}


class X8664Native(Native):
class X8664Linux(Linux):
@property
def name(self):
return 'native-x86_64'
def target(self):
return "x86_64-linux"

@property
def is_64bit(self):
Expand All @@ -50,10 +50,10 @@ def system_ads(self):
return {'light': 'system-xi-x86_64.ads'}


class Aarch64Native(Native):
class Aarch64Linux(Linux):
@property
def name(self):
return 'native-aarch64'
def target(self):
return "aarch64-linux"

@property
def is_64bit(self):
Expand Down
44 changes: 44 additions & 0 deletions linux/adaint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/syscall.h>
#include <unistd.h>
#include <sched.h>

void *
__gnat_lwp_self (void)
{
return (void *) syscall (__NR_gettid);
}

cpu_set_t *
__gnat_cpu_alloc (size_t count)
{
return CPU_ALLOC (count);
}

size_t
__gnat_cpu_alloc_size (size_t count)
{
return CPU_ALLOC_SIZE (count);
}

void
__gnat_cpu_free (cpu_set_t *set)
{
CPU_FREE (set);
}

void
__gnat_cpu_zero (size_t count, cpu_set_t *set)
{
CPU_ZERO_S (count, set);
}

void
__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
{
/* Ada handles CPU numbers starting from 1, while C identifies the first
CPU by a 0, so we need to adjust. */
CPU_SET_S (cpu - 1, count, set);
}
4 changes: 2 additions & 2 deletions support/data/target_options.gpr.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ abstract project Target_Options is
-- link against libgnat (itself).
-- Since -nostdlib also removes libgcc
-- from the linked libraries we have to
-- add -lgcc again.
LOPTIONS := LOPTIONS & ("-nostdlib", "-lgcc");
-- add -lc and -lgcc again.
LOPTIONS := LOPTIONS & ("-nostdlib", "-lc", "-lgcc");
end case;

-- Concatenate with common flags
Expand Down
44 changes: 38 additions & 6 deletions support/rts_sources/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@
'hie/a-textio__deos.ads', 'hie/a-textio__deos.adb',
'hie/s-macres.ads',
],
'linux_srcs': [
'hie/a-textio.ads',
'hie/a-textio__libc.adb',
'hie/g-io__zfp.ads',
'hie/g-io__zfp.adb',
'hie/g-io-put.adb',
'hie/s-macres.ads',
'hie/s-textio__libc.ads',
'hie/s-textio__libc.adb',
],
'pikeos_srcs': [
'hie/a-textio.ads',
'exit.c',
Expand All @@ -246,11 +256,15 @@
'vx_stack_info.c'],
'qnx_srcs': [
'exit.c',
'hie/g-io__zfp.ads', 'hie/g-io__zfp.adb',
'hie/g-io__zfp.ads',
'hie/g-io__zfp.adb',
'hie/g-io-put.adb',
'hie/a-textio.ads', 'hie/a-textio__qnx.adb',
'hie/a-textio.ads',
'hie/a-textio__qnx.adb',
'hie/s-macres.ads',
'hie/s-textio__qnx.ads', 'hie/s-textio__qnx.adb']
'hie/s-textio__qnx.ads',
'hie/s-textio__qnx.adb'
],
},

'common/32': {
Expand Down Expand Up @@ -282,6 +296,7 @@
'hie/s-assert__xi.adb',
'hie/s-memory__light.ads'],
'bb_srcs': ['hie/a-elchha__zfp.adb'],
'linux_srcs': ['hie/a-elchha__zfp.adb'],
'pikeos_srcs': ['hie/a-elchha__zfp.adb'],
'qnx_srcs': [
'hie/a-elchha__traceback.adb',
Expand All @@ -307,6 +322,7 @@
'hie/s-sssita.ads', 'hie/s-sssita.adb'],
'deos_srcs': [
'hie/s-thread__cert.ads', 'hie/s-thread__cert.adb'],
'linux_srcs': ['hie/s-sssita.ads', 'hie/s-sssita.adb'],
'pikeos_srcs': [
'hie/a-textio__pikeos-light.adb',
'hie/s-sssita.ads', 'hie/s-sssita.adb'],
Expand Down Expand Up @@ -1048,6 +1064,19 @@
'hie/a-nalofl__light.ads',
'hie/a-nallfl__light.ads',
'libgnat/a-naliop__nolibm.ads'],
'linux_srcs': [
'hie/a-ngelfu__cert.ads',
'hie/a-ngelfu__cert.adb',
'hie/a-nlelfu__cert.ads',
'hie/a-nuelfu__cert.ads',
'hie/s-gcmain__cert.ads',
'hie/s-gcmain__cert.adb',
'hie/a-nllefu__cert.ads',
'hie/a-nuaufl__light.ads',
'hie/a-nalofl__light.ads',
'hie/a-nallfl__light.ads',
'libgnat/a-naliop.ads',
],
'pikeos_srcs': [
'hie/a-ngelfu__ada.ads', 'hie/a-ngelfu__ada.adb',
'hie/a-nlelfu__ada.ads',
Expand Down Expand Up @@ -1713,15 +1742,18 @@
},
'gnat/parameters/light-small': {
'conditions': ['RTS_Profile:light', 'Memory_Profile:small'],
'bb_srcs': ['hie/s-parame__zfp_small.ads']
'bb_srcs': ['hie/s-parame__zfp_small.ads'],
'linux_srcs': ['hie/s-parame__zfp_small.ads'],
},
'gnat/parameters/light-large': {
'conditions': ['RTS_Profile:light', 'Memory_Profile:large'],
'bb_srcs': ['hie/s-parame__zfp.ads']
'bb_srcs': ['hie/s-parame__zfp.ads'],
'linux_srcs': ['hie/s-parame__zfp.ads'],
},
'gnat/parameters/light-huge': {
'conditions': ['RTS_Profile:light', 'Memory_Profile:huge'],
'bb_srcs': ['hie/s-parame__zfp_huge.ads']
'bb_srcs': ['hie/s-parame__zfp_huge.ads'],
'linux_srcs': ['hie/s-parame__zfp_huge.ads'],
},

# Cert
Expand Down
51 changes: 51 additions & 0 deletions windows/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from support.bsp_sources.target import DFBBTarget


class Windows(DFBBTarget):
def __init__(self):
super().__init__()
self.add_gnat_sources("src/s-macres__native.adb", "src/s-textio__stdio.adb")

@property
def name(self):
return self.target

def has_libc(self, profile):
return True

def dump_runtime_xml(self, rts_name, rts):
return (
'<?xml version="1.0" ?>\n'
"<gprconfig>\n"
" <configuration>\n"
" </configuration>\n"
"</gprconfig>\n"
)

@property
def is_legacy_format(self):
return True


class X86Windows(Windows):
@property
def target(self):
return "x86-windows"

@property
def system_ads(self):
return {"light": "system-native-x86-light.ads"}


class X8664Windows(Windows):
@property
def target(self):
return "x86_64-windows"

@property
def is_64bit(self):
return True

@property
def system_ads(self):
return {"light": "system-native-x86-light.ads"}

0 comments on commit 62ca4f1

Please sign in to comment.