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

How could we cross compile ck? #193

Closed
zetalog opened this issue Jun 21, 2022 · 5 comments
Closed

How could we cross compile ck? #193

zetalog opened this issue Jun 21, 2022 · 5 comments

Comments

@zetalog
Copy link
Contributor

zetalog commented Jun 21, 2022

It looks the "configure" is a hand-writing script not a script generated by autoconf, and contains the following code:

cat << EOF > .1.c
#include <stdio.h>
int main(void) {
#if defined(_WIN32)
#if defined(__MINGW64__)
	puts("mingw64");
	return (0);
#elif defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION >= 3)
	puts("mingw32");
	return (0);
#else
	return (1);
#endif /* __MINGW32__ && __MINGW32_MAJOR_VERSION >= 3 */
#elif defined(__clang__) && (__clang_major__ >= 3)
	puts("clang");
	return (0);
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5110)
	puts("suncc");
	return (0);
#elif defined(__GNUC__) && (__GNUC__ >= 4)
	puts("gcc");
	return (0);
#else
	return (1);
#endif
}
EOF

$CC -o .1 .1.c
COMPILER=`./.1 2> /dev/null`
r=$?
rm -f .1.c .1

The block is trying to execute a target binary via the following line and definitely will fail:

COMPILER=`./.1 2> /dev/null`

It thus looks like that the "ck" doesn't support cross compile.
Am I right? If not, please help to tell how could we cross compile ck.

Thanks in advance.

@zetalog
Copy link
Contributor Author

zetalog commented Jun 22, 2022

Other than this, it looks ck can perfectly support cross compilation.
I confirmed that by forcing a COMPILER name here to bypass the detection code.

So please help to fix the issue in the right way in ck upstream.
Thanks in advance.

@zetalog
Copy link
Contributor Author

zetalog commented Jun 22, 2022

Related PR:
#194

@zetalog
Copy link
Contributor Author

zetalog commented Jun 22, 2022

Below is the patch to bypass COMPILER detection:

Index: ck/configure
===================================================================
--- ck.orig/configure
+++ ck/configure
@@ -657,7 +669,8 @@ if test ! -x "${CC}"; then
 fi
 assert "$CC" "not found"

-cat << EOF > .1.c
+if test "x$COMPILER" = "x"; then
+       cat << EOF > .1.c
 #include <stdio.h>
 int main(void) {
 #if defined(_WIN32)
@@ -685,10 +698,11 @@ int main(void) {
 }
 EOF

-$CC -o .1 .1.c
-COMPILER=`./.1 2> /dev/null`
-r=$?
-rm -f .1.c .1
+       $CC -o .1 .1.c
+       COMPILER=`./.1 2> /dev/null`
+       r=$?
+       rm -f .1.c .1
+fi

 if test "$r" -ne 0; then
        assert "" "update compiler"

This may not be required by upstream if the issue can be properly handled.
But if you want, I can also push it to the upstream.

@sbahra
Copy link
Member

sbahra commented Jul 11, 2022

Thanks for patch!

@sbahra sbahra closed this as completed Jul 11, 2022
@jscheid-ventana
Copy link

@sbahra, I don't see #193 (comment) making it into the master branch. #194 did not include it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants