Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] crash: allow to build on non x86-64 machines
@ 2020-12-28 19:36 Cyrill Gorcunov
  2020-12-29 16:15 ` Alexander V. Tikhonov
  2020-12-29 16:34 ` Alexander Turenko
  0 siblings, 2 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2020-12-28 19:36 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

The general purpose registers were optional earlier
lets make them optional back allowing the code to
be compiled on non x86-64 machines.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Guys, obviously I didn't test on real non x86 machine.
But since we've been notifying from public chat that
people are trying to compile tarantool on arm lets
make a quick fix.

branch gorcunov/crash-cross-compile

 src/lib/core/crash.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/lib/core/crash.c b/src/lib/core/crash.c
index 8397603bc..5b50ed3c4 100644
--- a/src/lib/core/crash.c
+++ b/src/lib/core/crash.c
@@ -30,10 +30,11 @@
 /** Use strlcpy with destination as an array */
 #define strlcpy_a(dst, src) strlcpy(dst, src, sizeof(dst))
 
-#ifdef TARGET_OS_LINUX
-#ifndef __x86_64__
-# error "Non x86-64 architectures are not supported"
+#if defined(TARGET_OS_LINUX) && defined(__x86_64__)
+# define HAS_GREG
 #endif
+
+#ifdef HAS_GREG
 struct crash_greg {
 	uint64_t	r8;
 	uint64_t	r9;
@@ -64,7 +65,7 @@ struct crash_greg {
 	uint64_t	fpstate;
 	uint64_t	reserved1[8];
 };
-#endif /* TARGET_OS_LINUX */
+#endif /* HAS_GREG */
 
 static struct crash_info {
 	/**
@@ -76,7 +77,7 @@ static struct crash_info {
 	 */
 	void *context_addr;
 	void *siginfo_addr;
-#ifdef TARGET_OS_LINUX
+#ifdef HAS_GREG
 	/**
 	 * Registers contents.
 	 */
@@ -199,7 +200,7 @@ crash_collect(int signo, siginfo_t *siginfo, void *ucontext)
 	backtrace(start, sizeof(cinfo->backtrace_buf));
 #endif
 
-#ifdef TARGET_OS_LINUX
+#ifdef HAS_GREG
 	/*
 	 * uc_mcontext on libc level looks somehow strange,
 	 * they define an array of uint64_t where each register
@@ -411,7 +412,7 @@ crash_report_stderr(struct crash_info *cinfo)
 	fprintf(stderr, "  context: %p\n", cinfo->context_addr);
 	fprintf(stderr, "  siginfo: %p\n", cinfo->siginfo_addr);
 
-#ifdef TARGET_OS_LINUX
+#ifdef HAS_GREG
 # define fprintf_reg(__n, __v)				\
 	fprintf(stderr, "  %-9s0x%-17llx%lld\n",	\
 		__n, (long long)__v, (long long)__v)
@@ -441,7 +442,7 @@ crash_report_stderr(struct crash_info *cinfo)
 	fprintf_reg("oldmask", cinfo->greg.oldmask);
 	fprintf_reg("trapno", cinfo->greg.trapno);
 # undef fprintf_reg
-#endif /* TARGET_OS_LINUX */
+#endif /* HAS_GREG */
 
 	fprintf(stderr, "Current time: %u\n", (unsigned)time(0));
 	fprintf(stderr, "Please file a bug at "
-- 
2.26.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Tarantool-patches] [PATCH] crash: allow to build on non x86-64 machines
  2020-12-28 19:36 [Tarantool-patches] [PATCH] crash: allow to build on non x86-64 machines Cyrill Gorcunov
@ 2020-12-29 16:15 ` Alexander V. Tikhonov
  2020-12-29 16:34 ` Alexander Turenko
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander V. Tikhonov @ 2020-12-29 16:15 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tarantool-patches

Hi Cyrill, thanks for the patch, as I see no new degradation found in
gitlab-ci testing commit criteria pipeline [1], patch LGTM.

[1] - https://gitlab.com/tarantool/tarantool/-/pipelines/235181553

On Mon, Dec 28, 2020 at 10:36:22PM +0300, Cyrill Gorcunov via Tarantool-patches wrote:
> The general purpose registers were optional earlier
> lets make them optional back allowing the code to
> be compiled on non x86-64 machines.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> Guys, obviously I didn't test on real non x86 machine.
> But since we've been notifying from public chat that
> people are trying to compile tarantool on arm lets
> make a quick fix.
> 
> branch gorcunov/crash-cross-compile
> 
>  src/lib/core/crash.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/src/lib/core/crash.c b/src/lib/core/crash.c
> index 8397603bc..5b50ed3c4 100644
> --- a/src/lib/core/crash.c
> +++ b/src/lib/core/crash.c
> @@ -30,10 +30,11 @@
>  /** Use strlcpy with destination as an array */
>  #define strlcpy_a(dst, src) strlcpy(dst, src, sizeof(dst))
>  
> -#ifdef TARGET_OS_LINUX
> -#ifndef __x86_64__
> -# error "Non x86-64 architectures are not supported"
> +#if defined(TARGET_OS_LINUX) && defined(__x86_64__)
> +# define HAS_GREG
>  #endif
> +
> +#ifdef HAS_GREG
>  struct crash_greg {
>  	uint64_t	r8;
>  	uint64_t	r9;
> @@ -64,7 +65,7 @@ struct crash_greg {
>  	uint64_t	fpstate;
>  	uint64_t	reserved1[8];
>  };
> -#endif /* TARGET_OS_LINUX */
> +#endif /* HAS_GREG */
>  
>  static struct crash_info {
>  	/**
> @@ -76,7 +77,7 @@ static struct crash_info {
>  	 */
>  	void *context_addr;
>  	void *siginfo_addr;
> -#ifdef TARGET_OS_LINUX
> +#ifdef HAS_GREG
>  	/**
>  	 * Registers contents.
>  	 */
> @@ -199,7 +200,7 @@ crash_collect(int signo, siginfo_t *siginfo, void *ucontext)
>  	backtrace(start, sizeof(cinfo->backtrace_buf));
>  #endif
>  
> -#ifdef TARGET_OS_LINUX
> +#ifdef HAS_GREG
>  	/*
>  	 * uc_mcontext on libc level looks somehow strange,
>  	 * they define an array of uint64_t where each register
> @@ -411,7 +412,7 @@ crash_report_stderr(struct crash_info *cinfo)
>  	fprintf(stderr, "  context: %p\n", cinfo->context_addr);
>  	fprintf(stderr, "  siginfo: %p\n", cinfo->siginfo_addr);
>  
> -#ifdef TARGET_OS_LINUX
> +#ifdef HAS_GREG
>  # define fprintf_reg(__n, __v)				\
>  	fprintf(stderr, "  %-9s0x%-17llx%lld\n",	\
>  		__n, (long long)__v, (long long)__v)
> @@ -441,7 +442,7 @@ crash_report_stderr(struct crash_info *cinfo)
>  	fprintf_reg("oldmask", cinfo->greg.oldmask);
>  	fprintf_reg("trapno", cinfo->greg.trapno);
>  # undef fprintf_reg
> -#endif /* TARGET_OS_LINUX */
> +#endif /* HAS_GREG */
>  
>  	fprintf(stderr, "Current time: %u\n", (unsigned)time(0));
>  	fprintf(stderr, "Please file a bug at "
> -- 
> 2.26.2
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Tarantool-patches] [PATCH] crash: allow to build on non x86-64 machines
  2020-12-28 19:36 [Tarantool-patches] [PATCH] crash: allow to build on non x86-64 machines Cyrill Gorcunov
  2020-12-29 16:15 ` Alexander V. Tikhonov
@ 2020-12-29 16:34 ` Alexander Turenko
  2020-12-29 17:02   ` Cyrill Gorcunov
  1 sibling, 1 reply; 4+ messages in thread
From: Alexander Turenko @ 2020-12-29 16:34 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Vladislav Shpilevoy

On Mon, Dec 28, 2020 at 10:36:22PM +0300, Cyrill Gorcunov via Tarantool-patches wrote:
> The general purpose registers were optional earlier
> lets make them optional back allowing the code to
> be compiled on non x86-64 machines.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> Guys, obviously I didn't test on real non x86 machine.
> But since we've been notifying from public chat that
> people are trying to compile tarantool on arm lets
> make a quick fix.
> 
> branch gorcunov/crash-cross-compile

LGTM aside one non-critical comment below.

Pushed to master.

CCed Kirill.

> 
>  src/lib/core/crash.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/src/lib/core/crash.c b/src/lib/core/crash.c
> index 8397603bc..5b50ed3c4 100644
> --- a/src/lib/core/crash.c
> +++ b/src/lib/core/crash.c
> @@ -30,10 +30,11 @@
>  /** Use strlcpy with destination as an array */
>  #define strlcpy_a(dst, src) strlcpy(dst, src, sizeof(dst))
>  
> -#ifdef TARGET_OS_LINUX
> -#ifndef __x86_64__
> -# error "Non x86-64 architectures are not supported"
> +#if defined(TARGET_OS_LINUX) && defined(__x86_64__)
> +# define HAS_GREG
>  #endif

AFAIU, we usually set such flags from the build system (cmake) and just
use it in the code. It make the code a bit more clean.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Tarantool-patches] [PATCH] crash: allow to build on non x86-64 machines
  2020-12-29 16:34 ` Alexander Turenko
@ 2020-12-29 17:02   ` Cyrill Gorcunov
  0 siblings, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2020-12-29 17:02 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tml, Vladislav Shpilevoy

On Tue, Dec 29, 2020 at 07:34:12PM +0300, Alexander Turenko wrote:
> 
> AFAIU, we usually set such flags from the build system (cmake) and just
> use it in the code. It make the code a bit more clean.

Yes, I think we will make it so on top, later. 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-29 17:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 19:36 [Tarantool-patches] [PATCH] crash: allow to build on non x86-64 machines Cyrill Gorcunov
2020-12-29 16:15 ` Alexander V. Tikhonov
2020-12-29 16:34 ` Alexander Turenko
2020-12-29 17:02   ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox