From patchwork Thu Oct 20 18:25:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 55235 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A8FB38654A2 for ; Thu, 20 Oct 2022 18:26:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A8FB38654A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666290391; bh=kjl3Iy4hHmOuCWo6VuMlUKZC5myCNghtaRBMWNVi9UM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=NdmF93Vqi+XGo0q8N9s3VFydOxQgWtRBnlvatDQDqP4zc8JexPXuhcmPEDrScGKsK xOIC5B158kMkT7tYd6W0ZAeJ+/3jdhUhYb8SIdzjjTfY7hdl5XKr2HZSa9S7LSZD4C kY/g0jxJ3FRqGwYD24mAIlFwDCU7m2HHlokcxAlw= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id B48EE3865486 for ; Thu, 20 Oct 2022 18:26:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B48EE3865486 Received: by mail-pl1-x633.google.com with SMTP id u6so73579plq.12 for ; Thu, 20 Oct 2022 11:26:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kjl3Iy4hHmOuCWo6VuMlUKZC5myCNghtaRBMWNVi9UM=; b=hhDeaoqsmWHoLm1Po6U8ebL5vLcUw83pWgnjRoR13l2K3Si1ccQjslOOwREtaGtNu7 z6h22L0nXJIBK9mx2Ha4297yrxa20tKJRu0GLK5EF4MW+Anu2Czv+S93RN2zVsoXRjdZ c5d7w4WNb9WCYNdfu+QermaXRPAcZY1beDKR1GpYn/gCZHDIuEWyG3FyJHT5DxDUnPaY PyDrmlugTqxHReW7y15qAHzTeP65wThkvxvm02TbYieH2lUSWYofQM6KcITZbC0WYOT3 4jZrA00qQSFmHhTrSQ3z+ZUh7vzMVl7aS7de7FSar9+15SLKvtQve6zyoh1tVDSOUchp Nb9Q== X-Gm-Message-State: ACrzQf2eBS9lNnYGSxKomKw2N65YdpZ6Kdsc3L9SsFIYGWiYEr6F0mcg scPIymbBWr4j+r5MlNrNhiohbJPSb845cA== X-Google-Smtp-Source: AMsMyM7S5WRBtvDOcf7QYAEqwdA/89GtODUl/86VENFCX+2LMFP8JA7Ikk41A/KHOIIfMGl70MjY8g== X-Received: by 2002:a17:90b:1c11:b0:20d:459b:ef0e with SMTP id oc17-20020a17090b1c1100b0020d459bef0emr53217129pjb.129.1666290379114; Thu, 20 Oct 2022 11:26:19 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id w15-20020a17090a460f00b00202fbd9c21dsm115067pjg.48.2022.10.20.11.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:26:18 -0700 (PDT) To: elfutils-devel@sourceware.org Subject: [PATCH 00/25] Patches for building with mingw/gcc msvc/clang-cl Date: Fri, 21 Oct 2022 02:25:39 +0800 Message-Id: <20221020182603.815-1-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" 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 in eblclosebackend.c and eblopenbackend.c libelf/libdwfl: Remove "#define LIB_SYSTEM_H 1" in libelf_crc32.c and libdwfl_crc32.c use #include instead platform depended header 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 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%)