将 SWC 与 Alchemy 链接时崩溃

发布于 2024-08-28 13:54:57 字数 2509 浏览 9 评论 0原文

我有一个项目正在尝试用炼金术进行编译。它将编译 .o 和 .a 文件,但是当尝试创建 .swc 时,它将失败。它似乎因此错误而崩溃:

g++ -swc -o mylib.swc my-flex-interface.cpp mylib.a
    Cannot yet select: 0x279c810: ch,flag = AVM2ISD::CALL - A call instruction 0x279c7a0, 0x29c4350
    0   llc                                 0x00636dfe _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 6078
    1   llc                                 0x006373a2 _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 7522
    2   libSystem.B.dylib                   0x9530942b _sigtramp + 43
    3   ???                                 0xffffffff 0x0 + 4294967295
    4   libSystem.B.dylib                   0x953968e5 raise + 26
    5   libSystem.B.dylib                   0x953ac99c abort + 93
    6   llc                                 0x002f4fe0 _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel6Emit_7ERKN4llvm9SDOperandEj + 0
    7   llc                                 0x002f8e1b _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectCodeEN4llvm9SDOperandE + 2219
    8   llc                                 0x002fa193 _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectRootEN4llvm9SDOperandE + 819
    9   llc                                 0x002e6a2c _ZN4llvm19X86_64TargetMachineD0Ev + 65116
    10  llc                                 0x003de4ca _ZN4llvm11StoreSDNodeD1Ev + 1610
    11  llc                                 0x0040d3fe _ZN4llvm11StoreSDNodeD1Ev + 193918
    12  llc                                 0x0040f92e _ZN4llvm11StoreSDNodeD1Ev + 203438
    13  llc                                 0x005d1926 _ZN4llvm12FunctionPassD1Ev + 20998
    14  llc                                 0x005d1f3a _ZN4llvm12FunctionPassD1Ev + 22554
    15  llc                                 0x005d20c5 _ZN4llvm12FunctionPassD1Ev + 22949
    16  llc                                 0x00002e44 0x0 + 11844
    17  llc                                 0x00001f36 0x0 + 7990
    18  ???                                 0x00000006 0x0 + 6
    make[2]: *** [src/app/alchemy/sonic.swc] Error 6
    make[1]: *** [src/app/alchemy/CMakeFiles/alchemy.dir/all] Error 2
    make: *** [all] Error 2

我对 LLVM(Alchemy 在幕后使用的)不够熟悉,无法弄清楚此错误的含义。有什么想法吗?

I have a project I'm trying to compile with alchemy. It will compile .o and .a files, but when trying to create a .swc, it will fail. It appears to crash with this error:

g++ -swc -o mylib.swc my-flex-interface.cpp mylib.a
    Cannot yet select: 0x279c810: ch,flag = AVM2ISD::CALL - A call instruction 0x279c7a0, 0x29c4350
    0   llc                                 0x00636dfe _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 6078
    1   llc                                 0x006373a2 _ZNSt8_Rb_treeIN4llvm3sys4PathES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE13insert_uniqueERKS2_ + 7522
    2   libSystem.B.dylib                   0x9530942b _sigtramp + 43
    3   ???                                 0xffffffff 0x0 + 4294967295
    4   libSystem.B.dylib                   0x953968e5 raise + 26
    5   libSystem.B.dylib                   0x953ac99c abort + 93
    6   llc                                 0x002f4fe0 _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel6Emit_7ERKN4llvm9SDOperandEj + 0
    7   llc                                 0x002f8e1b _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectCodeEN4llvm9SDOperandE + 2219
    8   llc                                 0x002fa193 _ZN98_GLOBAL__N__Volumes_data_dev_FlaCC_llvm_2.1_lib_Target_AVM2_AVM2ISelDAGToDAG.cpp_00000000_F04616B616AVM2DAGToDAGISel10SelectRootEN4llvm9SDOperandE + 819
    9   llc                                 0x002e6a2c _ZN4llvm19X86_64TargetMachineD0Ev + 65116
    10  llc                                 0x003de4ca _ZN4llvm11StoreSDNodeD1Ev + 1610
    11  llc                                 0x0040d3fe _ZN4llvm11StoreSDNodeD1Ev + 193918
    12  llc                                 0x0040f92e _ZN4llvm11StoreSDNodeD1Ev + 203438
    13  llc                                 0x005d1926 _ZN4llvm12FunctionPassD1Ev + 20998
    14  llc                                 0x005d1f3a _ZN4llvm12FunctionPassD1Ev + 22554
    15  llc                                 0x005d20c5 _ZN4llvm12FunctionPassD1Ev + 22949
    16  llc                                 0x00002e44 0x0 + 11844
    17  llc                                 0x00001f36 0x0 + 7990
    18  ???                                 0x00000006 0x0 + 6
    make[2]: *** [src/app/alchemy/sonic.swc] Error 6
    make[1]: *** [src/app/alchemy/CMakeFiles/alchemy.dir/all] Error 2
    make: *** [all] Error 2

I'm not familiar enough with LLVM (which Alchemy uses under the hood) to figure out what this error means. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟燃烟灭 2024-09-04 13:54:57

从 Alchemy v0.5a 开始,编译 memcpy/memmove/memset 时,LLVM 前端有时(在 Mac OS X 上)会发出 Alchemy 后端链接器无法处理的中间代码。它将因“尚无法选择”错误而崩溃。

解决方法是在不同的平台(Ubuntu、Windows)上编译或覆盖 memcpy/memmove/memset 的实现:

static void * custom_memmove( void * destination, const void * source, size_t num ) {
  void *result;
  __asm__("%0 memmove(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num));
  return result;
}
static void * custom_memcpy ( void * destination, const void * source, size_t num ) {
  void *result;
  __asm__("%0 memcpy(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num));
  return result;
}
static void * custom_memset ( void * ptr, int value, size_t num ) {
  void *result;
  __asm__("%0 memset(%1, %2, %3)\n" : "=r"(result) : "r"(ptr), "r"(value), "r"(num));
  return result;
}
#define memmove custom_memmove
#define memcpy custom_memcpy
#define memset custom_memset

不幸的是,此解决方法需要将上述代码(通过 #include)放入使用 memcpy 的每个模块中。

最终,我通过覆盖 string.h 注入了 memcpy/memset/memmove 解决方法(使用 -I 和 #include_next),但这需要破解 ahacks/gcc 脚本,以便以正确的顺序处理 -I 标志:

sub dash_I
{
  my $arg = (shift);
  my $path;

  if($arg =~ /-I=?(.*)/)
    { $path = $1 } 
  else
    { $path = shift(ARGV) }
  my $ppath = $incmap{$path};
  my @pathes = $ppath ? @$ppath : ($path);

  # BUGFIX: insert user -I header search paths
  # early so that they override the system search paths
  #
  #push(@compile, map { "-I$_" } @pathes);
  splice(@compile, 1, 0, map { "-I$_" } @pathes);

  0
}

As of Alchemy v0.5a, when compiling memcpy/memmove/memset the LLVM frontend will sometimes (on Mac OS X) emit intermediate code that the Alchemy backend linker can't handle. It will crash with the "cannot yet select" error.

The workaround is either to compile on a different platform (Ubuntu, Windows) or to override the implementations of memcpy/memmove/memset:

static void * custom_memmove( void * destination, const void * source, size_t num ) {
  void *result;
  __asm__("%0 memmove(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num));
  return result;
}
static void * custom_memcpy ( void * destination, const void * source, size_t num ) {
  void *result;
  __asm__("%0 memcpy(%1, %2, %3)\n" : "=r"(result) : "r"(destination), "r"(source), "r"(num));
  return result;
}
static void * custom_memset ( void * ptr, int value, size_t num ) {
  void *result;
  __asm__("%0 memset(%1, %2, %3)\n" : "=r"(result) : "r"(ptr), "r"(value), "r"(num));
  return result;
}
#define memmove custom_memmove
#define memcpy custom_memcpy
#define memset custom_memset

Unfortunately this workaround requires putting the above code (via a #include) into every module that uses memcpy.

Ultimately, I injected the memcpy/memset/memmove workarounds by overriding string.h (using -I and #include_next), but this required hacking the achacks/gcc script so that the -I flags are processed in the right order:

sub dash_I
{
  my $arg = (shift);
  my $path;

  if($arg =~ /-I=?(.*)/)
    { $path = $1 } 
  else
    { $path = shift(ARGV) }
  my $ppath = $incmap{$path};
  my @pathes = $ppath ? @$ppath : ($path);

  # BUGFIX: insert user -I header search paths
  # early so that they override the system search paths
  #
  #push(@compile, map { "-I$_" } @pathes);
  splice(@compile, 1, 0, map { "-I$_" } @pathes);

  0
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文