Skip to content
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

Feature: add e2k (elbrus) architectures and mcst-lcc compiler #8032

Merged
merged 2 commits into from
Jan 13, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion conans/client/build/compiler_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def architecture_flag(settings):
return "/Qm32" if str(compiler_base) == "Visual Studio" else "-m32"
elif str(arch) == "x86_64":
return "/Qm64" if str(compiler_base) == "Visual Studio" else "-m64"
elif str(compiler) == "mcst-lcc":
return {"e2k-v2": "-march=elbrus-v2",
"e2k-v3": "-march=elbrus-v3",
"e2k-v4": "-march=elbrus-v4",
"e2k-v5": "-march=elbrus-v5",
"e2k-v6": "-march=elbrus-v6",
"e2k-v7": "-march=elbrus-v7"}.get(str(arch), "")
return ""


Expand Down Expand Up @@ -145,7 +152,7 @@ def build_type_flags(settings):
# Modules/Compiler/GNU.cmake
# clang include the gnu (overriding some things, but not build type) and apple clang
# overrides clang but it doesn't touch clang either
if str(compiler) in ["clang", "gcc", "apple-clang", "qcc"]:
if str(compiler) in ["clang", "gcc", "apple-clang", "qcc", "mcst-lcc"]:
# FIXME: It is not clear that the "-s" is something related with the build type
# cmake is not adjusting it
# -s: Remove all symbol table and relocation information from the executable.
Expand Down
36 changes: 34 additions & 2 deletions conans/client/build/cppstd_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def cppstd_flag(compiler, compiler_version, cppstd, compiler_base=None):
"clang": _cppstd_clang,
"apple-clang": _cppstd_apple_clang,
"Visual Studio": _cppstd_visualstudio,
"intel": cppstd_intel}.get(str(compiler), None)
"intel": cppstd_intel,
"mcst-lcc": _cppstd_mcst_lcc}.get(str(compiler), None)
flag = None
if func:
flag = func(str(compiler_version), str(cppstd))
Expand Down Expand Up @@ -62,7 +63,8 @@ def cppstd_default(settings):
"clang": _clang_cppstd_default(compiler_version),
"apple-clang": "gnu98", # Confirmed in apple-clang 9.1 with a simple "auto i=1;"
"Visual Studio": _visual_cppstd_default(compiler_version),
"intel": intel_cppstd_default(compiler_version)}.get(str(compiler), None)
"intel": intel_cppstd_default(compiler_version),
"mcst-lcc": _mcst_lcc_cppstd_default(compiler_version)}.get(str(compiler), None)
return default


Expand All @@ -89,6 +91,10 @@ def _intel_gcc_cppstd_default(_):
return "gnu98"


def _mcst_lcc_cppstd_default(compiler_version):
return "gnu14" if Version(compiler_version) >= "1.24" else "gnu98"


def _cppstd_visualstudio(visual_version, cppstd):
# https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version
v14 = None
Expand Down Expand Up @@ -274,3 +280,29 @@ def _cppstd_intel_gcc(intel_version, cppstd):
def _cppstd_intel_visualstudio(intel_version, cppstd):
flag = _cppstd_intel_common(intel_version, cppstd, None, None)
return "/Qstd=%s" % flag if flag else None


def _cppstd_mcst_lcc(mcst_lcc_version, cppstd):
v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = v20 = vgnu20 = None

if Version(mcst_lcc_version) >= "1.21":
v11 = "c++11"
vgnu11 = "gnu++11"
v14 = "c++14"
vgnu14 = "gnu++14"

if Version(mcst_lcc_version) >= "1.24":
v17 = "c++17"
vgnu17 = "gnu++17"

if Version(mcst_lcc_version) >= "1.25":
v20 = "c++2a"
vgnu20 = "gnu++2a"

flag = {"98": "c++98", "gnu98": "gnu++98",
"03": "c++03", "gnu03": "gnu++03",
"11": v11, "gnu11": vgnu11,
"14": v14, "gnu14": vgnu14,
"17": v17, "gnu17": vgnu17,
"20": v20, "gnu20": vgnu20}.get(cppstd)
return "-std=%s" % flag if flag else None
13 changes: 10 additions & 3 deletions conans/client/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
_t_default_settings_yml = Template(textwrap.dedent("""
# Only for cross building, 'os_build/arch_build' is the system that runs Conan
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX]
arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le]
arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]

# Only for building cross compilation tools, 'os_target/arch_target' is the system for
# which the tools generate code
os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino]
arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le]
arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]

# Rest of the settings are "host" settings:
# - For native building/cross building: Where the library/program will run.
Expand Down Expand Up @@ -53,7 +53,7 @@
Emscripten:
Neutrino:
version: ["6.4", "6.5", "6.6", "7.0", "7.1"]
arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le]
arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]
compiler:
sun-cc:
version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"]
Expand Down Expand Up @@ -106,6 +106,13 @@
version: ["4.4", "5.4", "8.3"]
libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne]
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]
mcst-lcc:
version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"]
base:
gcc:
<<: *gcc
threads: [None]
exceptions: [None]

build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]

Expand Down
9 changes: 8 additions & 1 deletion conans/client/conf/compiler_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
MSVC = "Visual Studio"
INTEL = "intel"
QCC = "qcc"
MCST_LCC = "mcst-lcc"


class CompilerId(object):
Expand Down Expand Up @@ -102,7 +103,13 @@ def __ne__(self, other):

def _parse_compiler_version(defines):
try:
if '__INTEL_COMPILER' in defines:
if '__LCC__' in defines and '__e2k__' in defines:
compiler = MCST_LCC
version = int(defines['__LCC__'])
major = int(version / 100)
minor = int(version % 100)
patch = int(defines['__LCC_MINOR__'])
elif '__INTEL_COMPILER' in defines:
compiler = INTEL
version = int(defines['__INTEL_COMPILER'])
major = int(version / 100)
Expand Down
14 changes: 14 additions & 0 deletions conans/client/conf/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ def _detect_compiler_version(result, output, profile_path):
result.append(("compiler.libcxx", "libstdc++"))
elif compiler == "sun-cc":
result.append(("compiler.libcxx", "libCstd"))
elif compiler == "mcst-lcc":
result.append(("compiler.base", "gcc")) # do the same for Intel?
result.append(("compiler.base.libcxx", "libstdc++"))
version = Version(version)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't like this code to be here and to be like that. ideally, CompilerId may detect base compiler (by inspecting __GNUC__ in addition to the __LCC__, but we still have old --version-based detection.

if version >= "1.24":
result.append(("compiler.base.version", "7.3"))
elif version >= "1.23":
result.append(("compiler.base.version", "5.5"))
elif version >= "1.21":
result.append(("compiler.base.version", "4.8"))
else:
result.append(("compiler.base.version", "4.4"))


def _detect_os_arch(result, output):
Expand All @@ -268,6 +280,8 @@ def _detect_os_arch(result, output):
else:
output.error("Your ARM '%s' architecture is probably not defined in settings.yml\n"
"Please check your conan.conf and settings.yml files" % arch)
elif arch.startswith('e2k'):
arch = OSInfo.get_e2k_architecture() or arch
elif OSInfo().is_aix:
arch = OSInfo.get_aix_architecture() or arch

Expand Down
2 changes: 1 addition & 1 deletion conans/client/generators/cmake_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ class CMakeCommonMacros:
if(NOT ${_CHECK_VERSION} VERSION_EQUAL ${_CONAN_VERSION})
conan_error_compiler_version()
endif()
elseif(CONAN_COMPILER STREQUAL "apple-clang" OR CONAN_COMPILER STREQUAL "sun-cc")
elseif(CONAN_COMPILER STREQUAL "apple-clang" OR CONAN_COMPILER STREQUAL "sun-cc" OR CONAN_COMPILER STREQUAL "mcst-lcc")
conan_split_version(${CONAN_COMPILER_VERSION} CONAN_COMPILER_MAJOR CONAN_COMPILER_MINOR)
if(NOT ${VERSION_MAJOR}.${VERSION_MINOR} VERSION_EQUAL ${CONAN_COMPILER_MAJOR}.${CONAN_COMPILER_MINOR})
conan_error_compiler_version()
Expand Down
108 changes: 106 additions & 2 deletions conans/client/migrations_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,8 +1816,112 @@
settings_1_31_2 = settings_1_31_1
settings_1_31_3 = settings_1_31_2
settings_1_31_4 = settings_1_31_3

settings_1_32_0 = settings_1_31_4
settings_1_32_1 = settings_1_32_0
settings_1_33_0 = """
# Only for cross building, 'os_build/arch_build' is the system that runs Conan
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX]
arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]

# Only for building cross compilation tools, 'os_target/arch_target' is the system for
# which the tools generate code
os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino]
arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]

# Rest of the settings are "host" settings:
# - For native building/cross building: Where the library/program will run.
# - For building cross compilation tools: Where the cross compiler will run.
os:
Windows:
subsystem: [None, cygwin, msys, msys2, wsl]
WindowsStore:
version: ["8.1", "10.0"]
WindowsCE:
platform: ANY
version: ["5.0", "6.0", "7.0", "8.0"]
Linux:
Macos:
version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0"]
Android:
api_level: ANY
iOS:
version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6"]
watchOS:
version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1"]
tvOS:
version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0"]
FreeBSD:
SunOS:
AIX:
Arduino:
board: ANY
Emscripten:
Neutrino:
version: ["6.4", "6.5", "6.6", "7.0", "7.1"]
arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]
compiler:
sun-cc:
version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"]
threads: [None, posix]
libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
gcc: &gcc
version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9",
"5", "5.1", "5.2", "5.3", "5.4", "5.5",
"6", "6.1", "6.2", "6.3", "6.4", "6.5",
"7", "7.1", "7.2", "7.3", "7.4", "7.5",
"8", "8.1", "8.2", "8.3", "8.4",
"9", "9.1", "9.2", "9.3",
"10", "10.1"]
libcxx: [libstdc++, libstdc++11]
threads: [None, posix, win32] # Windows MinGW
exception: [None, dwarf2, sjlj, seh] # Windows MinGW
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20]
Visual Studio: &visual_studio
runtime: [MD, MT, MTd, MDd]
version: ["8", "9", "10", "11", "12", "14", "15", "16"]
toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp,
v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp,
LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp,
LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2, v142,
llvm, ClangCL]
cppstd: [None, 14, 17, 20]
clang:
version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0",
"5.0", "6.0", "7.0", "7.1",
"8", "9", "10", "11"]
libcxx: [None, libstdc++, libstdc++11, libc++, c++_shared, c++_static]
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20]
runtime: [None, MD, MT, MTd, MDd]
apple-clang: &apple_clang
version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0"]
libcxx: [libstdc++, libc++]
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20]
intel:
version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "19.1"]
base:
gcc:
<<: *gcc
threads: [None]
exception: [None]
Visual Studio:
<<: *visual_studio
apple-clang:
<<: *apple_clang
qcc:
version: ["4.4", "5.4", "8.3"]
libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne]
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]
mcst-lcc:
version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"]
base:
gcc:
<<: *gcc
threads: [None]
exceptions: [None]

build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]


cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] # Deprecated, use compiler.cppstd
"""

settings_1_33_0 = settings_1_32_1
20 changes: 20 additions & 0 deletions conans/client/tools/oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def detected_architecture():
return "s390x"
elif "s390" in machine:
return "s390"
elif "e2k" in machine:
return OSInfo.get_e2k_architecture()

return None

Expand Down Expand Up @@ -344,6 +346,21 @@ def get_solaris_architecture():
elif "i386" in processor:
return "x86_64" if kernel_bitness == "64bit" else "x86"

@staticmethod
def get_e2k_architecture():
return {
"E1C+": "e2k-v4", # Elbrus 1C+ and Elbrus 1CK
"E2C+": "e2k-v2", # Elbrus 2CM
"E2C+DSP": "e2k-v2", # Elbrus 2C+
"E2C3": "e2k-v6", # Elbrus 2C3
"E2S": "e2k-v3", # Elbrus 2S (aka Elbrus 4C)
"E8C": "e2k-v4", # Elbrus 8C and Elbrus 8C1
"E8C2": "e2k-v5", # Elbrus 8C2 (aka Elbrus 8CB)
"E12C": "e2k-v6", # Elbrus 12C
"E16C": "e2k-v6", # Elbrus 16C
"E32C": "e2k-v7", # Elbrus 32C
}.get(platform.processor())

@staticmethod
def get_freebsd_version():
return platform.release().split("-")[0]
Expand Down Expand Up @@ -541,6 +558,9 @@ def get_gnu_triplet(os_, arch, compiler=None):
machine = "s390-ibm"
elif "sh4" in arch:
machine = "sh4"
elif "e2k" in arch:
# https://lists.gnu.org/archive/html/config-patches/2015-03/msg00000.html
machine = "e2k-unknown"

if machine is None:
raise ConanException("Unknown '%s' machine, Conan doesn't know how to "
Expand Down
13 changes: 13 additions & 0 deletions conans/test/unittests/client/build/compiler_flags_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ def test_arch_flag_intel(self, base, arch, flag):
"arch": arch})
self.assertEqual(architecture_flag(settings), flag)

@parameterized.expand([("e2k-v2", "-march=elbrus-v2"),
("e2k-v3", "-march=elbrus-v3"),
("e2k-v4", "-march=elbrus-v4"),
("e2k-v5", "-march=elbrus-v5"),
("e2k-v6", "-march=elbrus-v6"),
("e2k-v7", "-march=elbrus-v7"),
])
def test_arch_flag_mcst_lcc(self, arch, flag):
settings = MockSettings({"compiler": "mcst-lcc",
"compiler.base": "gcc",
"arch": arch})
self.assertEqual(architecture_flag(settings), flag)

@parameterized.expand([("gcc", "libstdc++", "_GLIBCXX_USE_CXX11_ABI=0"),
("gcc", "libstdc++11", "_GLIBCXX_USE_CXX11_ABI=1"),
("clang", "libstdc++", "_GLIBCXX_USE_CXX11_ABI=0"),
Expand Down
10 changes: 9 additions & 1 deletion conans/test/unittests/client/build/compiler_id_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from parameterized import parameterized

from conans.client.conf.compiler_id import detect_compiler_id, CompilerId, UNKNOWN_COMPILER, \
GCC, LLVM_GCC, CLANG, APPLE_CLANG, SUNCC, MSVC, INTEL, QCC
GCC, LLVM_GCC, CLANG, APPLE_CLANG, SUNCC, MSVC, INTEL, QCC, MCST_LCC
from conans.test.unittests.util.tools_test import RunnerMock


Expand Down Expand Up @@ -127,3 +127,11 @@ def test_qcc(self):
"#define __GNUC_PATCHLEVEL__ 4\n"
compiler_id = detect_compiler_id("qcc", runner=runner)
self.assertEqual(CompilerId(QCC, 4, 2, 4), compiler_id)

def test_mcst_lcc(self):
runner = RunnerMock()
runner.output = "#define __LCC__ 125\n" \
"#define __LCC_MINOR__ 6\n" \
"#define __e2k__ 1\n"
compiler_id = detect_compiler_id("lcc", runner=runner)
self.assertEqual(CompilerId(MCST_LCC, 1, 25, 6), compiler_id)