Skip to content

Commit 9840bcd

Browse files
authored
Merge pull request #2 from mathworks/dev_R2026a
Add support for Speedgoat Linux toolchain on MATLAB R2026a.
2 parents eb91903 + d9d7fb8 commit 9840bcd

File tree

9 files changed

+81
-8
lines changed

9 files changed

+81
-8
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="speedgoat-linux-toolchain.cmake" type="File"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="x64-speedgoat-linux-static.cmake" type="File"/>

toolbox/+vcpkg/buildVcpkgDeps.m

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function buildVcpkgDeps(manifestFolder, vpckgArguments, options)
3232
%% Figure out target triplet
3333

3434
% Initialize variables
35-
qnxSdpBat = '';
35+
targetEnvRootBat = '';
3636

3737
% Figure out target triplet if required
3838
if options.buildHostOnly
@@ -41,16 +41,28 @@ function buildVcpkgDeps(manifestFolder, vpckgArguments, options)
4141
targetTriplet = vcpkg.getTargetTriplet;
4242

4343
if contains(targetTriplet, 'qnx', 'IgnoreCase', true)
44-
% Using QNX with Siumink Real-Time Target Support Package
44+
% Using QNX with Simulink Real-Time Target Support Package
4545
slrealtime.qnxSetupFcn;
4646
qnxSpRoot = getenv('SLREALTIME_QNX_SP_ROOT');
4747
qnxVersion = getenv('SLREALTIME_QNX_VERSION');
4848

4949
if ispc
50-
qnxSdpBat = ['&& ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.bat')];
50+
targetEnvRootBat = ['&& ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.bat')];
5151
elseif isunix
5252
% Sourcing the .sh file for qcc compilation.
53-
qnxSdpBat = ['&& ',append('source ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.sh'))];
53+
targetEnvRootBat = ['&& ',append('source ',fullfile(qnxSpRoot,qnxVersion,'qnxsdp-env.sh'))];
54+
end
55+
elseif contains(targetTriplet, 'x64-speedgoat-linux', 'IgnoreCase', true)
56+
% Yocto cc specific implementation
57+
x64CCRoot = getenv('X64CC_ROOT');
58+
if isempty(x64CCRoot)
59+
%Error x64 cc root path not defined.
60+
error(message('slrealtime:utils:x64CCRootNotSet'));
61+
end
62+
if ispc
63+
targetEnvRootBat = ['&& ',fullfile(x64CCRoot,'toolchain','x64cc-setup-env.bat')];
64+
else
65+
error('Current host OS is still not supported.');
5466
end
5567
end
5668

@@ -67,7 +79,7 @@ function buildVcpkgDeps(manifestFolder, vpckgArguments, options)
6779

6880
% Build up vcpkg full command
6981
vcpkgCmd = ['cd ', manifestFolder, ' ',...
70-
qnxSdpBat,...
82+
targetEnvRootBat,...
7183
' && vcpkg install ',targetTriplet,' --host-triplet ', vcpkg.getHostTriplet,...
7284
' --overlay-triplets "', fullfile(vcpkg.getToolboxRoot,'overlay-triplets'), '" ', strjoin(vpckgArguments,' ')];
7385

toolbox/+vcpkg/getTargetTriplet.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
elseif isMATLABReleaseOlderThan('R2020b')
1313
triplet = 'x86-windows-static';
1414
else
15-
error('Target triplet is not supported for MATLAB R2026a and later yet. Use buildHostOnly.');
15+
% MATLAB R2026a or later
16+
if exist('speedgoat','file')
17+
triplet = 'x64-speedgoat-linux-static';
18+
end
1619
end
1720

1821
end

toolbox/overlay-triplets/qnx-toolchain.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if(NOT DEFINED ENV{QNX_HOST} OR NOT DEFINED ENV{QNX_TARGET})
1212
message(FATAL_ERROR "QNX environment not found. Please 'source qnxsdp-env.sh' first.")
1313
endif()
1414

15-
# Allow caller to choose architecture; default to aarch64
15+
# Allow caller to choose architecture; default to x86_64
1616
set(CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "QNX target arch (aarch64|armv7|x86_64)")
1717

1818
# Map arch → qcc variant string and sysroot suffix
@@ -43,7 +43,6 @@ set(CMAKE_CXX_COMPILER_TARGET ${QNX_QCC_VARIANT})
4343
set(CMAKE_SYSROOT "$ENV{QNX_TARGET}/${QNX_SYSROOT_SUFFIX}")
4444

4545
# Make sure CMake finds things in the QNX sysroot first
46-
set(CMAKE_FIND_ROOT_PATH "$ENV{QNX_TARGET}")
4746
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
4847
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
4948
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# speedgoat-linux-toolchain.cmake
2+
3+
# Require a modern-enough CMake
4+
cmake_minimum_required(VERSION 3.20)
5+
6+
# Tell CMake we target Linux
7+
set(CMAKE_SYSTEM_NAME Linux)
8+
9+
# Allow caller to choose architecture; default to x86_64
10+
set(CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "Speedgoat Linux target arch (aarch64|x86_64)")
11+
12+
# Compilers
13+
set(CMAKE_C_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-speedgoat-linux-gcc)
14+
set(CMAKE_CXX_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-speedgoat-linux-g++)
15+
16+
# Sysroot
17+
set(CMAKE_SYSROOT "$ENV{SDKTARGETSYSROOT}")
18+
19+
# Optimize for target architecture
20+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
21+
add_compile_options(-march=core2)
22+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
23+
add_compile_options(-march=armv8-a+crc)
24+
else()
25+
message(FATAL_ERROR "Unsupported processor architecture='${CMAKE_SYSTEM_PROCESSOR}'. Use aarch64|x86_64.")
26+
endif()
27+
28+
# Make sure CMake finds things in the sysroot first
29+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
30+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
31+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
32+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
33+
34+
# Set fPIC flag
35+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
set(VCPKG_TARGET_ARCHITECTURE x64)
2+
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
3+
4+
# Linkage preferences
5+
set(VCPKG_CRT_LINKAGE dynamic)
6+
set(VCPKG_LIBRARY_LINKAGE static) # common for embedded
7+
8+
# Pass environment variables
9+
set(VCPKG_ENV_PASSTHROUGH SDKTARGETSYSROOT;PATH)
10+
11+
# Absolute path to the chainloaded toolchain
12+
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE
13+
"${CMAKE_CURRENT_LIST_DIR}/speedgoat-linux-toolchain.cmake")
14+
15+
# Disable debug builds
16+
set(VCPKG_BUILD_TYPE release)

0 commit comments

Comments
 (0)