Merge pull request #6970 from valeriosetti/issue6857
driver-only ECDSA: get testing parity in PK
diff --git a/ChangeLog.d/c-build-helper-hostcc.txt b/ChangeLog.d/c-build-helper-hostcc.txt
new file mode 100644
index 0000000..86182c3
--- /dev/null
+++ b/ChangeLog.d/c-build-helper-hostcc.txt
@@ -0,0 +1,4 @@
+Features
+ * Use HOSTCC (if it is set) when compiling C code during generation of the
+ configuration-independent files. This allows them to be generated when
+ CC is set for cross compilation.
diff --git a/scripts/mbedtls_dev/c_build_helper.py b/scripts/mbedtls_dev/c_build_helper.py
index 459afba..9bd17d6 100644
--- a/scripts/mbedtls_dev/c_build_helper.py
+++ b/scripts/mbedtls_dev/c_build_helper.py
@@ -89,6 +89,37 @@
}
''')
+def compile_c_file(c_filename, exe_filename, include_dirs):
+ """Compile a C source file with the host compiler.
+
+ * ``c_filename``: the name of the source file to compile.
+ * ``exe_filename``: the name for the executable to be created.
+ * ``include_dirs``: a list of paths to include directories to be passed
+ with the -I switch.
+ """
+ # Respect $HOSTCC if it is set
+ cc = os.getenv('HOSTCC', None)
+ if cc is None:
+ cc = os.getenv('CC', 'cc')
+ cmd = [cc]
+
+ proc = subprocess.Popen(cmd,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.PIPE,
+ universal_newlines=True)
+ cc_is_msvc = 'Microsoft (R) C/C++' in proc.communicate()[1]
+
+ cmd += ['-I' + dir for dir in include_dirs]
+ if cc_is_msvc:
+ # MSVC has deprecated using -o to specify the output file,
+ # and produces an object file in the working directory by default.
+ obj_filename = exe_filename[:-4] + '.obj'
+ cmd += ['-Fe' + exe_filename, '-Fo' + obj_filename]
+ else:
+ cmd += ['-o' + exe_filename]
+
+ subprocess.check_call(cmd + [c_filename])
+
def get_c_expression_values(
cast_to, printf_format,
expressions,
@@ -128,24 +159,8 @@
expressions)
)
c_file.close()
- cc = os.getenv('CC', 'cc')
- cmd = [cc]
- proc = subprocess.Popen(cmd,
- stdout=subprocess.DEVNULL,
- stderr=subprocess.PIPE,
- universal_newlines=True)
- cc_is_msvc = 'Microsoft (R) C/C++' in proc.communicate()[1]
-
- cmd += ['-I' + dir for dir in include_path]
- if cc_is_msvc:
- # MSVC has deprecated using -o to specify the output file,
- # and produces an object file in the working directory by default.
- obj_name = exe_name[:-4] + '.obj'
- cmd += ['-Fe' + exe_name, '-Fo' + obj_name]
- else:
- cmd += ['-o' + exe_name]
- subprocess.check_call(cmd + [c_name])
+ compile_c_file(c_name, exe_name, include_path)
if keep_c:
sys.stderr.write('List of {} tests kept at {}\n'
.format(caller, c_name))
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index 2b789c3..92050eb 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -3269,7 +3269,7 @@
}
support_test_m32_o0 () {
case $(uname -m) in
- *64*) true;;
+ amd64|x86_64) true;;
*) false;;
esac
}