[申威适配] 申威sw_64统信UOS编译python greenlet报错‘slp_switch’ was not declared in this scope; did you mean ‘g_s

申威在编译python等三方库由于架构问题导致编译失败,搜了很多没有相关资料,适配了一些国产uos、kylin系统,简单写下解决编译greenlet的问题

问题报错:

src/greenlet/greenlet_slp_switch.hpp:69:6: 错误:#error "greenlet needs to be ported to this platform, or taught how to detect your compiler properly."
   69 | #    error \
	  |      ^~~~~
In file included from src/greenlet/greenlet.cpp:31:
src/greenlet/TGreenlet.cpp: 在成员函数‘virtual greenlet::Greenlet::switchstack_result_t greenlet::Greenlet::g_switchstack()’中:
src/greenlet/TGreenlet.cpp:183:15: 错误:‘slp_switch’ was not declared in this scope; did you mean ‘g_switch’?
  183 |         err = slp_switch();
	  |               ^~~~~~~~~~
	  |               g_switch
In file included from src/greenlet/greenlet_internal.hpp:15,
				 from src/greenlet/greenlet.cpp:19:
src/greenlet/greenlet.cpp: 在全局域:
src/greenlet/greenlet.cpp:194:31: 警告:‘void slp_restore_state_trampoline()’ defined but not used [-Wunused-function]
  194 | static void GREENLET_NOINLINE(slp_restore_state_trampoline)()
	  |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/greenlet/greenlet_compiler_compat.hpp:70:63: 附注:in definition of macro ‘GREENLET_NOINLINE’
   70 | #    define GREENLET_NOINLINE(name) __attribute__((noinline)) name
	  |                                                               ^~~~
src/greenlet/greenlet.cpp:190:30: 警告:‘int slp_save_state_trampoline(char*)’ defined but not used [-Wunused-function]
  190 | static int GREENLET_NOINLINE(slp_save_state_trampoline)(char* stackref)
	  |                              ^~~~~~~~~~~~~~~~~~~~~~~~~
src/greenlet/greenlet_compiler_compat.hpp:70:63: 附注:in definition of macro ‘GREENLET_NOINLINE’
   70 | #    define GREENLET_NOINLINE(name) __attribute__((noinline)) name
	  |                                                               ^~~~
error: command '/usr/bin/g++' failed with exit code 1
[end of output]

下载greenlet源码包

vi src/greenlet/slp_platformselect.h
加入引用

#elif defined(__GNUC__) && defined(__sw_64__)
#include "platform/switch_sw_64_unix.h" /* gcc on SW_64 */

cd src/greenlet/platform/
vi switch_sw_64_unix.h

#define STACK_REFPLUS 1

#ifdef SLP_EVAL
#define STACK_MAGIC 0

#define REGS_TO_SAVE "$9", "$10", "$11", "$12", "$13", "$14", "$15", \
                     "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9"

static int
slp_switch(void)
{
  register int ret;
  register long *stackref, stsizediff;
  __asm__ volatile ("" : : : REGS_TO_SAVE);
  __asm__ volatile ("mov $30, %0" : "=r" (stackref) : );
  {
      SLP_SAVE_STATE(stackref, stsizediff);
      __asm__ volatile (
	  "addl $30, %0, $30\n\t"
	  : /* no outputs */
	  : "r" (stsizediff)
	  );
      SLP_RESTORE_STATE();
  }
  __asm__ volatile ("" : : : REGS_TO_SAVE);
  __asm__ volatile ("mov $31, %0" : "=r" (ret) : );
  return ret;
}

#endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Moke丶青

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值