[00/25] Patches for building with mingw/gcc msvc/clang-cl

Message ID 20221020182603.815-1-luoyonggang@gmail.com
Headers
Series Patches for building with mingw/gcc msvc/clang-cl |

Message

Yonggang Luo Oct. 20, 2022, 6:25 p.m. UTC
  I split it into small patches for easier to review

Yonggang Luo (25):
  Rename 'hello2.spec.' -> 'hello2.spec' 'hello3.spec.' -> 'hello3.spec'
  ignore build directory
  libebl: There is no need #include <dlfcn.h> in eblclosebackend.c and
    eblopenbackend.c
  libelf/libdwfl: Remove "#define LIB_SYSTEM_H 1" in libelf_crc32.c and
    libdwfl_crc32.c
  use #include <system.h> instead platform depended header <endian.h> in
    libdw/memory-access.h
  move platform depended include into system.h of libebl
  move platform depended include into system.h of libasm, libcpu, libdw,
    libdwfl and libdwelf
  Use configure to detect HAVE_DECL_MMAP and use it for system doesn't
    provide sys/mman.h
  include libgen.h in system.h
  libcpu: Remove the need of NMNES by using enum
  libcpu: Use __asm instead asm that can be recognized by both clang-cl
    and gcc
  libcpu: Use "#define FCT_mod$64r_m FCT_mod$r_m" is enough and can be
    recognized by clang-cl on windows in i386_data.h
  libdw: typeof -> __typeof that can be recognized by both clang-cl and
    gcc
  libdw: check __OPTIMIZE__ in dwarf_whatattr.c and dwarf_whatform.c to
    match the header
  lib: Implement error properly even when not HAVE_ERR_H
  libeu: Move the implementation of  pwrite_retry, write_retry and
    pread_retry from header to source
  libelf: uid_t, gid_t and mode_t are not comes with msvcrt, so using
    long/unsigned long instead on win32
  lib: Use NOT_HAVE_LIBINTL to guard #include <libintl.h>
  libelf: F_GETFD may not predefined with msvc/mingw, guard the usage of
    it
  Add function sys_get_page_size to replace platform dependent sysconf
    (_SC_PAGESIZE)
  libasm: stdio_ext.h are not present on win32
  libebl/libdwelf: define ssize_t and pid_t for MSVC within installed
    header libdwelf.h and libebl.h
  libasm/debuginfod: fchmod doesn't present on win32
  lib: isatty is not available on windows
  Fixes building with msvc/clang mingw/gcc

 .gitignore                                    |    1 +
 .vscode/settings.json                         |  124 ++
 CMakeLists.txt                                |  106 +
 README                                        |    2 +-
 backends/CMakeLists.txt                       |  136 ++
 config-cmake/config.h                         |   40 +
 config-cmake/win32-gnu/search.h               |    3 +
 config-cmake/win32-msvc/dirent.c              |  872 ++++++++
 config-cmake/win32-msvc/dirent.h              |  339 +++
 config-cmake/win32-msvc/search.h              |   21 +
 config-cmake/win32-msvc/sys/time.h            |    1 +
 .../win32/ar.h                                |   32 +-
 config-cmake/win32/argp-ba.c                  |   23 +
 config-cmake/win32/argp-eexist.c              |   30 +
 config-cmake/win32/argp-fmtstream.c           |  456 ++++
 config-cmake/win32/argp-fmtstream.h           |  112 +
 config-cmake/win32/argp-help.c                | 1861 +++++++++++++++++
 config-cmake/win32/argp-parse.c               | 1373 ++++++++++++
 config-cmake/win32/argp-pv.c                  |   22 +
 config-cmake/win32/argp-pvh.c                 |   25 +
 config-cmake/win32/argp-shims.c               |   27 +
 config-cmake/win32/argp-shims.h               |   20 +
 config-cmake/win32/argp.h                     |  520 +++++
 config-cmake/win32/internal.h                 |  163 ++
 config-cmake/win32/obstack.h                  |  535 +++++
 configure.ac                                  |    1 +
 debuginfod/debuginfod-client.c                |    4 +-
 lib/CMakeLists.txt                            |   36 +
 lib/Makefile.am                               |    2 +-
 lib/color.c                                   |    6 +-
 lib/crc32_file.c                              |    6 +-
 lib/error.c                                   |    9 +-
 lib/eu-config.h                               |   11 +
 lib/system.c                                  |  516 +++++
 lib/system.h                                  |  157 +-
 libasm/CMakeLists.txt                         |   59 +
 libasm/asm_abort.c                            |    1 -
 libasm/asm_addint8.c                          |    2 -
 libasm/asm_begin.c                            |    9 +-
 libasm/asm_end.c                              |    4 +-
 libasm/libasmP.h                              |    3 +
 libcpu/CMakeLists.txt                         |   34 +
 libcpu/Makefile.am                            |    2 +-
 libcpu/i386_data.h                            |    2 +-
 libcpu/i386_disasm.c                          |    3 +-
 libcpu/i386_parse.y                           |   13 +-
 libcpu/memory-access.h                        |    3 +-
 libdw/CMakeLists.txt                          |  152 ++
 libdw/dwarf_begin_elf.c                       |    4 +-
 libdw/dwarf_end.c                             |    1 -
 libdw/dwarf_getsrc_file.c                     |    2 +-
 libdw/dwarf_setalt.c                          |    2 -
 libdw/dwarf_whatattr.c                        |    3 +-
 libdw/dwarf_whatform.c                        |    3 +-
 libdw/libdw_find_split_unit.c                 |    1 -
 libdw/memory-access.h                         |   13 +-
 libdwelf/CMakeLists.txt                       |   36 +
 libdwelf/dwelf_elf_begin.c                    |    2 -
 libdwelf/dwelf_strtab.c                       |    3 +-
 libdwelf/libdwelf.h                           |    5 +
 libdwfl/CMakeLists.txt                        |   92 +
 libdwfl/argp-std.c                            |    1 -
 libdwfl/core-file.c                           |    6 -
 libdwfl/dwfl_build_id_find_debuginfo.c        |    2 -
 libdwfl/dwfl_build_id_find_elf.c              |    1 -
 libdwfl/dwfl_end.c                            |    1 -
 libdwfl/dwfl_frame.c                          |    1 -
 libdwfl/dwfl_module.c                         |    1 -
 libdwfl/dwfl_module_getdwarf.c                |    1 -
 libdwfl/dwfl_module_getsrc_file.c             |    2 +-
 libdwfl/dwfl_report_elf.c                     |    2 -
 libdwfl/dwfl_segment_report_module.c          |    4 +-
 libdwfl/find-debuginfo.c                      |    7 +-
 libdwfl/gzip.c                                |    2 -
 libdwfl/image-header.c                        |    4 -
 libdwfl/libdwfl_crc32.c                       |    1 -
 libdwfl/link_map.c                            |    4 +-
 libdwfl/linux-kernel-modules.c                |    2 +-
 libdwfl/linux-pid-attach.c                    |    1 -
 libdwfl/linux-proc-maps.c                     |    2 +-
 libdwfl/offline.c                             |    1 -
 libdwfl/open.c                                |    2 -
 libebl/CMakeLists.txt                         |   80 +
 libebl/eblauxvinfo.c                          |    3 +-
 libebl/eblclosebackend.c                      |    1 -
 libebl/eblcorenote.c                          |    3 +-
 libebl/ebldynamictagname.c                    |    2 +-
 libebl/eblobjnote.c                           |   10 +-
 libebl/eblobjnotetypename.c                   |    3 +-
 libebl/eblopenbackend.c                       |    5 +-
 libebl/eblresolvesym.c                        |    3 +-
 libebl/libebl.h                               |    5 +
 libebl/libeblP.h                              |    4 +-
 libelf/CMakeLists.txt                         |  168 ++
 libelf/elf32_updatefile.c                     |    5 +-
 libelf/elf_begin.c                            |    7 +-
 libelf/elf_end.c                              |    2 +
 libelf/elf_update.c                           |    5 +-
 libelf/libelf.h                               |    6 +
 libelf/libelf_crc32.c                         |    1 -
 src/addr2line.c                               |    4 +-
 src/ar.c                                      |    2 +-
 src/nm.c                                      |    4 +-
 src/ranlib.c                                  |    2 +-
 src/stack.c                                   |    2 +-
 src/strings.c                                 |    2 +-
 src/strip.c                                   |    2 +-
 tests/Makefile.am                             |    2 +-
 .../{hello2.spec. => hello2.spec}             |    0
 .../{hello3.spec. => hello3.spec}             |    0
 110 files changed, 8241 insertions(+), 186 deletions(-)
 create mode 100644 .vscode/settings.json
 create mode 100644 CMakeLists.txt
 create mode 100644 backends/CMakeLists.txt
 create mode 100644 config-cmake/config.h
 create mode 100644 config-cmake/win32-gnu/search.h
 create mode 100644 config-cmake/win32-msvc/dirent.c
 create mode 100644 config-cmake/win32-msvc/dirent.h
 create mode 100644 config-cmake/win32-msvc/search.h
 create mode 100644 config-cmake/win32-msvc/sys/time.h
 copy libdw/dwarf_whatattr.c => config-cmake/win32/ar.h (73%)
 create mode 100644 config-cmake/win32/argp-ba.c
 create mode 100644 config-cmake/win32/argp-eexist.c
 create mode 100644 config-cmake/win32/argp-fmtstream.c
 create mode 100644 config-cmake/win32/argp-fmtstream.h
 create mode 100644 config-cmake/win32/argp-help.c
 create mode 100644 config-cmake/win32/argp-parse.c
 create mode 100644 config-cmake/win32/argp-pv.c
 create mode 100644 config-cmake/win32/argp-pvh.c
 create mode 100644 config-cmake/win32/argp-shims.c
 create mode 100644 config-cmake/win32/argp-shims.h
 create mode 100644 config-cmake/win32/argp.h
 create mode 100644 config-cmake/win32/internal.h
 create mode 100644 config-cmake/win32/obstack.h
 create mode 100644 lib/CMakeLists.txt
 create mode 100644 lib/system.c
 create mode 100644 libasm/CMakeLists.txt
 create mode 100644 libcpu/CMakeLists.txt
 create mode 100644 libdw/CMakeLists.txt
 create mode 100644 libdwelf/CMakeLists.txt
 create mode 100644 libdwfl/CMakeLists.txt
 create mode 100644 libebl/CMakeLists.txt
 create mode 100644 libelf/CMakeLists.txt
 rename tests/debuginfod-rpms/{hello2.spec. => hello2.spec} (100%)
 rename tests/debuginfod-rpms/{hello3.spec. => hello3.spec} (100%)