Test that g++ and Clang++ can compile assembly

When there's no C compiler available
pull/1095/head
Nirbheek Chauhan 8 years ago
parent 0cd11747f1
commit 38f6fee86d
  1. 16
      test cases/common/127 cpp and asm/meson.build
  2. 8
      test cases/common/127 cpp and asm/retval-arm.S
  3. 8
      test cases/common/127 cpp and asm/retval-x86.S
  4. 8
      test cases/common/127 cpp and asm/retval-x86_64.S
  5. 5
      test cases/common/127 cpp and asm/symbol-underscore.h
  6. 16
      test cases/common/127 cpp and asm/trivial.cc

@ -0,0 +1,16 @@
project('c++ and assembly test', 'cpp')
sources = ['trivial.cc']
# If the compiler cannot compile assembly, don't use it
if meson.get_compiler('cpp').get_id() != 'msvc'
cpu = host_machine.cpu_family()
sources += ['retval-' + cpu + '.S']
cpp_args = ['-DUSE_ASM']
message('Using ASM')
else
cpp_args = ['-DNO_USE_ASM']
endif
exe = executable('trivialprog', sources,
cpp_args : cpp_args)
test('runtest', exe)

@ -0,0 +1,8 @@
#include "symbol-underscore.h"
.text
.globl SYMBOL_NAME(get_retval)
SYMBOL_NAME(get_retval):
mov r0, #0
mov pc, lr

@ -0,0 +1,8 @@
#include "symbol-underscore.h"
.text
.globl SYMBOL_NAME(get_retval)
SYMBOL_NAME(get_retval):
xorl %eax, %eax
retl

@ -0,0 +1,8 @@
#include "symbol-underscore.h"
.text
.globl SYMBOL_NAME(get_retval)
SYMBOL_NAME(get_retval):
xorl %eax, %eax
retq

@ -0,0 +1,5 @@
#if defined(__WIN32__) || defined(__APPLE__)
# define SYMBOL_NAME(name) _##name
#else
# define SYMBOL_NAME(name) name
#endif

@ -0,0 +1,16 @@
#include<iostream>
extern "C" {
int get_retval(void);
}
int main(int argc, char **argv) {
std::cout << "C++ seems to be working." << std::endl;
#if defined(USE_ASM)
return get_retval();
#elif defined(NO_USE_ASM)
return 0;
#else
#error "Forgot to pass asm define"
#endif
}
Loading…
Cancel
Save