ci_conf.linux.rb (3952B)
1 require_relative 'linux' 2 3 def strip fname 4 d = opt.run_dir 5 base = File.join d, fname 6 return unless !File.exist?("#{base}.strip_stamp") || 7 File.mtime(base) != File.mtime("#{base}.strip_stamp") 8 9 run d, %W(objcopy --only-keep-debug #{fname} #{fname}.debug) 10 run d, %W(chmod -x #{fname}.debug) 11 run d, %W(strip --strip-unneeded -R .comment -R .GCC.command.line -R .gnu_debuglink #{fname}) 12 run d, %W(objcopy --add-gnu-debuglink=#{fname}.debug #{fname}) 13 run d, %W(touch -r#{fname} #{fname}.strip_stamp) 14 end 15 16 lin_cond = -> { opt.os.start_with? 'linux' } 17 step :linux_opts, always_after: :default_values, before: :os_opts, cond: lin_cond do 18 opt.triplet_oses = %w(linux-gnu) 19 opt.shlib_pattern = 'lib%s.so' 20 opt.executable_pattern = '%s' 21 22 opt.valgrind_opts = %W( 23 --suppressions=#{File.join opt.tools_dir, 'valgrind.supp'} 24 --leak-check=full 25 --track-origins=yes 26 --show-leak-kinds=all 27 ) 28 end 29 30 step :linux_strip, always_after: :default_values, after: :do_build, 31 before: :build, cond: lin_cond do 32 next if [false, "false", "no"].include? opt.strip 33 opt.executables.each do |e| 34 strip "build/#{e}" if File.exist? File.join(opt.run_dir, "build/#{e}") 35 end 36 end 37 38 test_step :test_valgrind, cond: -> { !opt.is_cross && opt.os.start_with?('linux') } do 39 Linux.clonens_wait do 40 run opt.run_dir, 'valgrind', *opt.valgrind_opts, '--', 41 *get_test_cmdline, '-tce=*[no_valgrind]*' 42 end 43 end 44 45 # steamrt 46 srt_cond = -> do 47 opt.os == 'linux_steamrt' && opt.architecture == 'amd64' && 48 opt.steamrt_amd64_sysroot 49 end 50 step :linux_steamrt_opts, always_after: :linux_opts, before: :os_opts, 51 cond: srt_cond do 52 sysroot = opt.steamrt_amd64_sysroot 53 opt.config_opts.append '--all-bundled' 54 55 opt.compile_flags.append '--sysroot', sysroot 56 env.LINKFLAGS.append '--sysroot', sysroot 57 58 # define: old glibc doesn't know about clang 59 if opt.compiler.start_with? 'clang' 60 opt.compile_flags.append \ 61 '-D__extern_always_inline=extern __always_inline __attribute__((__gnu_inline__))' 62 end 63 64 # -lrt only needed with glibc < 2.17 65 env.LINKFLAGS.concat %w(-Wl,--as-needed -lpthread -lrt -Wl,--no-as-needed) 66 67 env.PKG_CONFIG_PATH = Dir.glob "#{sysroot.globescape}/usr/lib/{,*/}pkgconfig" 68 env.PKG_CONFIG_SYSROOT_DIR = sysroot 69 opt.steamrt_sysroot_ld_library_path = 70 Dir.glob("#{sysroot.globescape}/{,usr/}lib/{,*-linux-gnu}").join ':' 71 end 72 73 test_step :test_linux_steamrt_chroot, cond: -> { !opt.is_cross && srt_cond[] } do 74 uid = Process.uid 75 gid = Process.gid 76 pid = Linux.clone Linux::CLONE_NEWUSER | Linux::CLONE_NEWPID | 77 Linux::CLONE_NEWNS | Linux::CLONE_NEWIPC | Linux::CLONE_NEWNET do 78 einfo "Chroot into #{opt.steamrt_amd64_sysroot}" 79 Linux.uid_gid_map uid, gid 80 Dir.chdir opt.steamrt_amd64_sysroot 81 Linux.mount '/', '/', nil, Linux::MS_REC | Linux::MS_PRIVATE 82 Linux.mount 'none', 'proc', 'proc', Linux::MS_NOSUID | Linux::MS_NODEV | 83 Linux::MS_RDONLY 84 Linux.mount '/dev', 'dev', nil, Linux::MS_BIND | Linux::MS_REC 85 Linux.mount opt.run_dir, 'test', nil, Linux::MS_BIND | Linux::MS_REC 86 Dir.chroot '.' 87 run '/test', *get_test_cmdline 88 rescue Exception 89 puts $!.full_message 90 exit! 1 91 end 92 Process.wait pid 93 fail "Subprocess failed: #{$?}" unless $?.success? 94 end 95 96 test_step :test_linux_steamrt_qemu, cond: srt_cond do 97 qemu_args = %W( 98 -E LD_LIBRARY_PATH=#{opt.steamrt_sysroot_ld_library_path} 99 ) 100 if opt.architecture == 'amd64' 101 run opt.tools_dir, env.HOST_CC || env.CC, '-O2', '-shared', 102 'qemu_vdso_fix_linux_amd64.c', '-o', 'qemu_vdso_fix_linux_amd64.so' 103 out = File.join opt.tools_dir, 'qemu_vdso_fix_linux_amd64.so' 104 qemu_args.append '-E', "LD_PRELOAD=#{out}" 105 end 106 107 env.QEMU_CPU = 'u3-64bit-minimal' 108 env.QEMU_EXECVE = which 'qemu-x86_64' 109 env.QEMU_LD_PREFIX = opt.steamrt_amd64_sysroot 110 run opt.run_dir, 'qemu-x86_64', *qemu_args, '--', *get_test_cmdline 111 end