Skip to content

Commit

Permalink
fix: use C++ 17 compiler for ICU (#414)
Browse files Browse the repository at this point in the history
* fix: use C++ 17 compiler for ICU

* wip

* hack CXX env var to force C++17

* test intl

* test intl

* add retry for CI test download

* patch

* separate intl with newer icu c++ patch

---------

Co-authored-by: crazywhalecc <[email protected]>
  • Loading branch information
dunglas and crazywhalecc authored Apr 22, 2024
1 parent 21dbb8a commit 6b96feb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
max_attempts: 3
retry_on: error
command: |
bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug
bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3
- name: "Run Build Tests (build)"
run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug
26 changes: 26 additions & 0 deletions src/SPC/builder/extension/intl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace SPC\builder\extension;

use SPC\builder\Extension;
use SPC\store\FileSystem;
use SPC\util\CustomExt;

#[CustomExt('intl')]
class intl extends Extension
{
public function patchBeforeBuildconf(): bool
{
// TODO: remove the following line when https://github.com/php/php-src/pull/14002 will be released
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/intl/config.m4', 'PHP_CXX_COMPILE_STDCXX(11', 'PHP_CXX_COMPILE_STDCXX(17');
// Also need to use clang++ -std=c++17 to force override the default C++ standard
if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) {
f_putenv('CXX=' . $env . ' -std=c++17');
} else {
f_putenv('CXX=clang++ -std=c++17');
}
return true;
}
}
2 changes: 1 addition & 1 deletion src/SPC/builder/linux/library/icu.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class icu extends LinuxLibraryBase
protected function build(): void
{
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"';
$cxxflags = 'CXXFLAGS="-std=c++11"';
$cxxflags = 'CXXFLAGS="-std=c++17"';
$ldflags = 'LDFLAGS="-static"';
shell()->cd($this->source_dir . '/source')
->exec(
Expand Down
2 changes: 1 addition & 1 deletion src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'uuid',
'Linux', 'Darwin' => 'intl,posix',
'Windows' => 'mbstring,pdo_sqlite,mbregex',
};

Expand Down

0 comments on commit 6b96feb

Please sign in to comment.