-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
phosg: support tests; phosg, resource_dasm: some fixes for older systems and PPC #18103
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
62fd804
phosg: add support for tests
barracuda156 7cbb821
phosg: set compiler.cxx_standard 2020
barracuda156 f83dec0
phosg: fixes for older systems and PPC
barracuda156 4dca4cf
resource_dasm: compiler.cxx_standard 2020, legacysupport PG
barracuda156 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
devel/phosg/files/0001-Encoding.hh-define-__STDC_FORMAT_MACROS.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
From af3d036dbc3c295a05789267db2002dafc170ad3 Mon Sep 17 00:00:00 2001 | ||
From: Sergey Fedorov <[email protected]> | ||
Date: Tue, 28 Mar 2023 00:46:39 +0700 | ||
Subject: [PATCH 1/5] Encoding.hh: define __STDC_FORMAT_MACROS | ||
|
||
--- | ||
src/Encoding.hh | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/src/Encoding.hh b/src/Encoding.hh | ||
index 41343e9..2c1beee 100644 | ||
--- src/Encoding.hh | ||
+++ src/Encoding.hh | ||
@@ -1,5 +1,6 @@ | ||
#pragma once | ||
|
||
+#define __STDC_FORMAT_MACROS | ||
#include <stdint.h> | ||
#include <inttypes.h> | ||
|
23 changes: 23 additions & 0 deletions
23
devel/phosg/files/0002-Image.hh-define-__darwin_ssize_t.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
From b3fe3a1675100660da408f76f22bddfb1af4d9d8 Mon Sep 17 00:00:00 2001 | ||
From: Sergey Fedorov <[email protected]> | ||
Date: Tue, 28 Mar 2023 01:04:07 +0700 | ||
Subject: [PATCH 2/5] Image.hh: define __darwin_ssize_t | ||
|
||
--- | ||
src/Image.hh | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/src/Image.hh b/src/Image.hh | ||
index 76448cd..8aa9417 100644 | ||
--- src/Image.hh | ||
+++ src/Image.hh | ||
@@ -9,6 +9,9 @@ | ||
|
||
#include "Platform.hh" | ||
|
||
+#ifdef __APPLE__ | ||
+typedef __darwin_ssize_t ssize_t; | ||
+#endif | ||
|
||
// an Image represents a drawing canvas. this class is fairly simple; it | ||
// supports reading/writing individual pixels, drawing lines, and saving the |
21 changes: 21 additions & 0 deletions
21
devel/phosg/files/0003-Network.cc-add-missing-cstring-header.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
From adc9ad09c1fc4d2a1c452a0f27ecd9e0518c8649 Mon Sep 17 00:00:00 2001 | ||
From: Sergey Fedorov <[email protected]> | ||
Date: Tue, 28 Mar 2023 01:07:36 +0700 | ||
Subject: [PATCH 3/5] Network.cc: add missing cstring header | ||
|
||
--- | ||
src/Network.cc | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/src/Network.cc b/src/Network.cc | ||
index 2e77df5..841868f 100644 | ||
--- src/Network.cc | ||
+++ src/Network.cc | ||
@@ -21,6 +21,7 @@ | ||
|
||
#include "Filesystem.hh" | ||
#include "Strings.hh" | ||
+#include <cstring> | ||
|
||
using namespace std; | ||
|
41 changes: 41 additions & 0 deletions
41
devel/phosg/files/0004-CMakeLists-fix-libatomic-for-macOS-ppc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
From 83854a38491856c8fbaea9fe8bed04754ea6cafe Mon Sep 17 00:00:00 2001 | ||
From: Sergey Fedorov <[email protected]> | ||
Date: Tue, 28 Mar 2023 01:36:33 +0700 | ||
Subject: [PATCH 4/5] CMakeLists: fix libatomic for macOS ppc | ||
|
||
--- | ||
CMakeLists.txt | 9 ++++++--- | ||
1 file changed, 6 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index ffe2368..053d92d 100644 | ||
--- CMakeLists.txt | ||
+++ CMakeLists.txt | ||
@@ -8,10 +8,12 @@ project(phosg) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
-if (MSVC) | ||
+if(MSVC) | ||
# Disabled warnings: | ||
# 4458 = declaration of '%s' hides class member (I use this->x for members) | ||
add_compile_options(/W4 /WX /wd4458) | ||
+elseif(APPLE AND ${CMAKE_OSX_ARCHITECTURES} MATCHES "ppc|ppc64") | ||
+ add_compile_options(-fpermissive -Wall -Wextra -Wno-strict-aliasing -Wno-unused-result -Wno-overflow) | ||
else() | ||
add_compile_options(-Wall -Wextra -Werror -Wno-strict-aliasing -Wno-unused-result -Wno-overflow) | ||
endif() | ||
@@ -31,10 +33,11 @@ add_library(phosg src/Encoding.cc src/Filesystem.cc src/Hash.cc src/Image.cc src | ||
target_link_libraries(phosg pthread z) | ||
|
||
# It seems that on some Linux variants (e.g. Raspbian) we also need -latomic, | ||
-# but this library does not exist on others (e.g. Ubuntu) nor on macOS | ||
+# but this library does not exist on others (e.g. Ubuntu). | ||
+# Linking to libatomic is also needed on macOS ppc32. Use CMAKE_OSX_ARCHITECTURES to take care of Rosetta case. | ||
message(STATUS "Target architecture is ${CMAKE_HOST_SYSTEM_PROCESSOR}") | ||
string(FIND ${CMAKE_HOST_SYSTEM_PROCESSOR} "armv" IS_LINUX_ARMV) | ||
-if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64" OR ${IS_LINUX_ARMV} GREATER_EQUAL 0) | ||
+if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64" OR ${IS_LINUX_ARMV} GREATER_EQUAL 0 OR ${CMAKE_OSX_ARCHITECTURES} STREQUAL "ppc") | ||
target_link_libraries(phosg atomic) | ||
endif() | ||
|
136 changes: 136 additions & 0 deletions
136
devel/phosg/files/0005-Filesystem-replacement-for-fmemopen.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
From 0b9460cc026fe69ece6d6a96740bbc1d31c91d31 Mon Sep 17 00:00:00 2001 | ||
From: Sergey Fedorov <[email protected]> | ||
Date: Tue, 28 Mar 2023 01:24:42 +0700 | ||
Subject: [PATCH 5/5] Filesystem: replacement for fmemopen | ||
|
||
--- | ||
src/Filesystem.cc | 94 +++++++++++++++++++++++++++++++++++++++++++++++ | ||
src/Filesystem.hh | 13 +++++++ | ||
2 files changed, 107 insertions(+) | ||
|
||
diff --git a/src/Filesystem.cc b/src/Filesystem.cc | ||
index 884128b..36d2764 100644 | ||
--- src/Filesystem.cc | ||
+++ src/Filesystem.cc | ||
@@ -678,3 +678,97 @@ unordered_map<int, short> Poll::poll(int timeout_ms) { | ||
} | ||
return ret; | ||
} | ||
+ | ||
+#ifdef __APPLE__ | ||
+#include <AvailabilityMacros.h> | ||
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101300 | ||
+// https://github.com/NimbusKit/memorymapping/blob/master/src/fmemopen.c | ||
+ | ||
+#include <sys/mman.h> | ||
+ | ||
+struct fmem { | ||
+ size_t pos; | ||
+ size_t size; | ||
+ char *buffer; | ||
+}; | ||
+typedef struct fmem fmem_t; | ||
+ | ||
+static int readfn(void *handler, char *buf, int size) { | ||
+ fmem_t *mem = handler; | ||
+ size_t available = mem->size - mem->pos; | ||
+ | ||
+ if (size > available) { | ||
+ size = available; | ||
+ } | ||
+ memcpy(buf, mem->buffer + mem->pos, sizeof(char) * size); | ||
+ mem->pos += size; | ||
+ | ||
+ return size; | ||
+} | ||
+ | ||
+static int writefn(void *handler, const char *buf, int size) { | ||
+ fmem_t *mem = handler; | ||
+ size_t available = mem->size - mem->pos; | ||
+ | ||
+ if (size > available) { | ||
+ size = available; | ||
+ } | ||
+ memcpy(mem->buffer + mem->pos, buf, sizeof(char) * size); | ||
+ mem->pos += size; | ||
+ | ||
+ return size; | ||
+} | ||
+ | ||
+static fpos_t seekfn(void *handler, fpos_t offset, int whence) { | ||
+ size_t pos; | ||
+ fmem_t *mem = handler; | ||
+ | ||
+ switch (whence) { | ||
+ case SEEK_SET: { | ||
+ if (offset >= 0) { | ||
+ pos = (size_t)offset; | ||
+ } else { | ||
+ pos = 0; | ||
+ } | ||
+ break; | ||
+ } | ||
+ case SEEK_CUR: { | ||
+ if (offset >= 0 || (size_t)(-offset) <= mem->pos) { | ||
+ pos = mem->pos + (size_t)offset; | ||
+ } else { | ||
+ pos = 0; | ||
+ } | ||
+ break; | ||
+ } | ||
+ case SEEK_END: pos = mem->size + (size_t)offset; break; | ||
+ default: return -1; | ||
+ } | ||
+ | ||
+ if (pos > mem->size) { | ||
+ return -1; | ||
+ } | ||
+ | ||
+ mem->pos = pos; | ||
+ return (fpos_t)pos; | ||
+} | ||
+ | ||
+static int closefn(void *handler) { | ||
+ free(handler); | ||
+ return 0; | ||
+} | ||
+ | ||
+FILE *fmemopen(void *buf, size_t size, const char *mode) { | ||
+ // This data is released on fclose. | ||
+ fmem_t* mem = (fmem_t *) malloc(sizeof(fmem_t)); | ||
+ | ||
+ // Zero-out the structure. | ||
+ memset(mem, 0, sizeof(fmem_t)); | ||
+ | ||
+ mem->size = size; | ||
+ mem->buffer = buf; | ||
+ | ||
+ // funopen's man page: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html | ||
+ return funopen(mem, readfn, writefn, seekfn, closefn); | ||
+} | ||
+#endif | ||
+#endif | ||
diff --git a/src/Filesystem.hh b/src/Filesystem.hh | ||
index fcaf9b8..63ebbf2 100644 | ||
--- src/Filesystem.hh | ||
+++ src/Filesystem.hh | ||
@@ -20,6 +20,19 @@ | ||
#include <utility> | ||
#include <vector> | ||
|
||
+#ifdef __APPLE__ | ||
+ #include <AvailabilityMacros.h> | ||
+ #if MAC_OS_X_VERSION_MAX_ALLOWED < 101300 | ||
+ // https://github.com/NimbusKit/memorymapping/blob/master/src/fmemopen.h | ||
+ #if defined __cplusplus | ||
+ extern "C" { | ||
+ #endif | ||
+ FILE *fmemopen(void *buf, size_t size, const char *mode); | ||
+ #ifdef __cplusplus | ||
+ } | ||
+ #endif | ||
+ #endif | ||
+#endif | ||
|
||
|
||
std::string basename(const std::string& filename); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@barracuda156 your dedication to fixing ports on older systems is insane! Thank you for working on this 👍
Are you running bleeding-edge MacPorts on your machine? I think
compiler.cxx_standard 2020
just sets the 2017 standard on stable MacPorts since support was only added 3 days ago (macports/macports-base@f23dca5).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harens Okay, but setting 2017 would make no difference now, but will have to be changed anyway later to 2020? Or do I miss something?
Alternatively we need to blacklist several versions of GCC, because otherwise they get picked, and build fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking more along those lines. Keep the cxx 20 but some other compilers might need to be blacklisted. From the mentioned commit: