-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add arm-gnu-toolchain #17528
base: master
Are you sure you want to change the base?
Add arm-gnu-toolchain #17528
Changes from 41 commits
00809af
1a735ef
07632d9
fdd859d
ffaed2e
504c8e6
3cd8a1a
440afa2
bc0230f
c17d1c7
6fefba9
fed10c4
e30da31
64f064c
a8968be
851d0f3
0c3ca6b
9c698a4
d4edd65
541f858
6448b9f
ff2b73e
0c94f6e
c8906c1
0981407
0b65315
14e6d2c
a28fe30
1a75ea9
e308e2d
c83aab4
ff4b349
846a44f
4f8e712
78e4dbb
1ea11e2
788da36
7e96199
9335e69
08b5b41
27e5f5a
6924257
afb3ea1
e070224
5ae0081
fd4e56e
e92d618
e8dded8
5fb035b
1741da0
67e3e90
5ecab5b
b35a29e
4d765ad
a46b734
0560d7e
c6c2357
aa783a8
7971cc2
5ccd502
c6bc92c
e7ae67e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
sources: | ||
"11.3.0": | ||
"Linux": | ||
"x86_64": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz" | ||
sha256: "d420d87f68615d9163b99bbb62fe69e85132dc0a8cd69fca04e813597fe06121" | ||
"armv8": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-aarch64-arm-none-eabi.tar.xz" | ||
sha256: "6c713c11d018dcecc16161f822517484a13af151480bbb722badd732412eb55e" | ||
"Macos": | ||
"x86_64": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-darwin-x86_64-arm-none-eabi.tar.xz" | ||
sha256: "826353d45e7fbaa9b87c514e7c758a82f349cb7fc3fd949423687671539b29cf" | ||
"armv8": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-darwin-x86_64-arm-none-eabi.tar.xz" | ||
sha256: "826353d45e7fbaa9b87c514e7c758a82f349cb7fc3fd949423687671539b29cf" | ||
"Windows": | ||
"x86_64": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi.zip" | ||
sha256: "23f24595aa575fba4fdb0cb086df4b053862af60837502cb7e52bd4fb3d76c36" | ||
"12.2.1": | ||
"Linux": | ||
"x86_64": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz" | ||
sha256: "84be93d0f9e96a15addd490b6e237f588c641c8afdf90e7610a628007fc96867" | ||
"armv8": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-aarch64-arm-none-eabi.tar.xz" | ||
sha256: "7ee332f7558a984e239e768a13aed86c6c3ac85c90b91d27f4ed38d7ec6b3e8c" | ||
"Macos": | ||
"x86_64": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz" | ||
sha256: "00c0eeb57ae92332f216151ac66df6ba17d2d3b306dac86f4006006f437b2902" | ||
"armv8": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-darwin-arm64-arm-none-eabi.tar.xz" | ||
sha256: "21a9e875250bcb0db8df4cb23dd43c94c00a1d3b98ecba9cdd6ed51586b12248" | ||
"Windows": | ||
"x86_64": | ||
url: "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-mingw-w64-i686-arm-none-eabi.zip" | ||
sha256: "ad1427496cde9bbe7604bc448ec6e115c6538e04af1c8275795ebb1c2b7b2830" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
from conan import ConanFile | ||
from conan.tools.files import get, copy, download | ||
from conan.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
|
||
required_conan_version = ">=1.50.0" | ||
|
||
|
||
class ArmGnuToolchain(ConanFile): | ||
name = "arm-gnu-toolchain" | ||
license = "GPL-3.0-only" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads" | ||
description = ("Conan installer for the GNU Arm Embedded Toolchain") | ||
topics = ("gcc", "compiler", "embedded", "arm", "cortex", "cortex-m", | ||
"cortex-m0", "cortex-m0+", "cortex-m1", "cortex-m3", "cortex-m4", | ||
"cortex-m4f", "cortex-m7", "cortex-m23", "cortex-m55", | ||
"cortex-m35p", "cortex-m33") | ||
settings = "os", "arch", 'compiler', 'build_type' | ||
exports_sources = "toolchain.cmake" | ||
package_type = "application" | ||
short_paths = True | ||
|
||
@property | ||
def download_info(self): | ||
version = self.version | ||
os = str(self._settings_build.os) | ||
arch = str(self._settings_build.arch) | ||
return self.conan_data.get("sources", {}).get(version, {}).get(os, {}).get(arch) | ||
|
||
@property | ||
def license_url(self): | ||
return "https://gist.githubusercontent.com/kammce/dc566a05f6ab2787ceef5b706012e7a2/raw/4cb8ab752d7c0f87cc074afa4e548a2be8766210/EULA.html" | ||
|
||
@property | ||
def _settings_build(self): | ||
return getattr(self, "settings_build", self.settings) | ||
|
||
def package_id(self): | ||
del self.info.settings.compiler | ||
del self.info.settings.build_type | ||
|
||
def validate(self): | ||
supported_build_operating_systems = ["Linux", "Macos", "Windows"] | ||
if not self._settings_build.os in supported_build_operating_systems: | ||
raise ConanInvalidConfiguration( | ||
f"The build os '{self._settings_build.os}' is not supported. " | ||
f"Pre-compiled binaries are only available for {supported_build_operating_systems}." | ||
) | ||
|
||
supported_build_architectures = { | ||
"Linux": ["armv8", "x86_64"], | ||
"Macos": ["armv8", "x86_64"], | ||
"Windows": ["x86_64"], | ||
} | ||
if ( | ||
not self._settings_build.arch | ||
in supported_build_architectures[str(self._settings_build.os)] | ||
): | ||
raise ConanInvalidConfiguration( | ||
f"The build architecture '{self._settings_build.arch}' is not supported for {self._settings_build.os}. " | ||
f"Pre-compiled binaries are only available for {supported_build_architectures[str(self._settings_build.os)]}." | ||
) | ||
|
||
def source(self): | ||
pass | ||
|
||
def build(self): | ||
download(self, self.license_url, "LICENSE", verify=False) | ||
|
||
get(self, | ||
**self.conan_data["sources"][self.version][str(self._settings_build.os)][str(self._settings_build.arch)], | ||
strip_root=True) | ||
|
||
def package(self): | ||
destination = os.path.join(self.package_folder, "bin/") | ||
|
||
copy(self, pattern="arm-none-eabi/*", src=self.build_folder, | ||
dst=destination, keep_path=True) | ||
copy(self, pattern="bin/*", src=self.build_folder, | ||
dst=destination, keep_path=True) | ||
copy(self, pattern="include/*", src=self.build_folder, | ||
dst=destination, keep_path=True) | ||
copy(self, pattern="lib/*", src=self.build_folder, | ||
dst=destination, keep_path=True) | ||
copy(self, pattern="libexec/*", src=self.build_folder, | ||
dst=destination, keep_path=True) | ||
copy(self, pattern="share/*", src=self.build_folder, | ||
dst=destination, keep_path=True) | ||
|
||
license_dir = os.path.join(self.package_folder, "licenses/") | ||
copy(self, pattern="LICENSE*", src=self.build_folder, | ||
dst=license_dir, keep_path=True) | ||
|
||
resource_dir = os.path.join(self.package_folder, "res/") | ||
copy(self, pattern="toolchain.cmake", src=self.build_folder, | ||
dst=resource_dir, keep_path=True) | ||
|
||
def package_info(self): | ||
self.cpp_info.includedirs = [] | ||
|
||
bin_folder = os.path.join(self.package_folder, "bin/bin") | ||
self.cpp_info.bindirs = [bin_folder] | ||
self.buildenv_info.append_path("PATH", bin_folder) | ||
|
||
self.conf_info.define( | ||
"tools.cmake.cmaketoolchain:system_name", "Generic") | ||
self.conf_info.define( | ||
"tools.cmake.cmaketoolchain:system_processor", "ARM") | ||
self.conf_info.define("tools.build.cross_building:can_run", False) | ||
self.conf_info.define("tools.build:compiler_executables", { | ||
"c": "arm-none-eabi-gcc", | ||
"cpp": "arm-none-eabi-g++", | ||
"asm": "arm-none-eabi-as", | ||
}) | ||
|
||
f = os.path.join(self.package_folder, "res/toolchain.cmake") | ||
self.conf_info.append("tools.cmake.cmaketoolchain:user_toolchain", f) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
# Required because Conan does not emit `set(CMAKE_SYSTEM_NAME "GENERIC")` or | ||
# `set(CMAKE_SYSTEM_PROCESSOR "ARM")` causing host flags to be leacked to CMake | ||
# in the conan_toolchain.cmake | ||
set(CMAKE_TOOLCHAIN_FILE ../toolchain.cmake) | ||
|
||
project(test_package LANGUAGES CXX) | ||
|
||
set(test_package_compiler_flags -mcpu=cortex-m0plus | ||
-mfloat-abi=soft | ||
--specs=nosys.specs | ||
--specs=nano.specs) | ||
|
||
add_executable(${PROJECT_NAME} main.cpp) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally noob question here, but is this C++20 requirement only because of internal test package implementation, or does the toolchain itself expect it (I doubt it but better to confirm!)? |
||
target_compile_options(${PROJECT_NAME} PRIVATE ${test_package_compiler_flags}) | ||
target_link_options(${PROJECT_NAME} PRIVATE ${test_package_compiler_flags}) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, cmake_layout | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualBuildEnv" | ||
|
||
def build_requirements(self): | ||
self.tool_requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
if str(self.settings.compiler) == "gcc": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This if smells iffy. Also (and this is just me maybe missing something else) why is this check here and not on the validate() method of the recipe? Any usecase? |
||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
# Executables generated by this toolchain will never work on a host | ||
# machine and thus can never be executed. | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <sys/stat.h> | ||
#include <unistd.h> | ||
|
||
#include <cstdarg> | ||
#include <cstdint> | ||
#include <cstdio> | ||
#include <cstring> | ||
|
||
int | ||
main() | ||
{ | ||
int a = 5; | ||
int b = 12; | ||
|
||
return a + b; | ||
} | ||
|
||
// Stub newlib implementations to keep linker happy | ||
extern "C" | ||
{ | ||
/// Dummy implementation of getpid | ||
int _getpid_r() | ||
{ | ||
return 1; | ||
} | ||
|
||
/// Dummy implementation of kill | ||
int _kill_r(int, int) | ||
{ | ||
return -1; | ||
} | ||
|
||
/// Dummy implementation of fstat, makes the assumption that the "device" | ||
/// representing, in this case STDIN, STDOUT, and STDERR as character devices. | ||
int _fstat_r([[maybe_unused]] int file, struct stat* status) | ||
{ | ||
status->st_mode = S_IFCHR; | ||
return 0; | ||
} | ||
|
||
int _write_r([[maybe_unused]] int file, | ||
[[maybe_unused]] const char* ptr, | ||
int length) | ||
{ | ||
return length; | ||
} | ||
|
||
int _read_r([[maybe_unused]] FILE* file, | ||
[[maybe_unused]] char* ptr, | ||
int length) | ||
{ | ||
return length; | ||
} | ||
|
||
// Dummy implementation of _lseek | ||
int _lseek_r([[maybe_unused]] int file, | ||
[[maybe_unused]] int ptr, | ||
[[maybe_unused]] int dir) | ||
{ | ||
return 0; | ||
} | ||
|
||
// Dummy implementation of close | ||
int _close_r([[maybe_unused]] int file) | ||
{ | ||
return -1; | ||
} | ||
|
||
// Dummy implementation of isatty | ||
int _isatty_r([[maybe_unused]] int file) | ||
{ | ||
return 1; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Append current directory to CMAKE_MODULE_PATH for making device specific | ||
# cmake modules visible | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) | ||
|
||
# Skip Working compiler test which tends to fail in CMake due to it using build | ||
# target architecture flags and not host architecture flags. | ||
set(CMAKE_CXX_COMPILER_WORKS TRUE) | ||
set(CMAKE_C_COMPILER_WORKS TRUE) | ||
|
||
# Need to force system to Generic & ARM as leaving this to Conan will result in | ||
# pollution from host profile settings | ||
set(CMAKE_SYSTEM_NAME Generic) | ||
set(CMAKE_SYSTEM_PROCESSOR arm) | ||
|
||
# Target definition | ||
set(TOOLCHAIN arm-none-eabi) | ||
|
||
# Perform compiler test with static library | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
|
||
# Set toolchain compilers | ||
set(CMAKE_C_COMPILER ${TOOLCHAIN}-gcc${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN}-g++${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(CMAKE_ASM_COMPILER ${TOOLCHAIN}-gcc${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(CMAKE_AR ${TOOLCHAIN}-ar${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(CMAKE_SIZE_UTIL ${TOOLCHAIN}-size${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(CMAKE_OBJDUMP ${TOOLCHAIN}-objdump${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(CMAKE_OBJCOPY ${TOOLCHAIN}-objcopy${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_BINARY_DIR}) | ||
|
||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
versions: | ||
"11.3.0": | ||
folder: "all" | ||
"12.2.1": | ||
folder: "all" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the whole toolchain needed? This does not test the package on a standalone way because it includes the file from the CCI tree itself.
Also, is there no way to define the missing variables using the CMake helpers in Conan? I would have expected it to be doable