Skip to content
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

Add intl/ICU support #67

Merged
merged 4 commits into from
Jun 2, 2023
Merged

Conversation

mpociot
Copy link
Contributor

@mpociot mpociot commented Jun 2, 2023

This PR adds support for the intl extension by compiling ICU statically and closes #66 .

I only tested MacOS support so far but modified the Linux build settings accordingly.

The download link for ICU points to a fixed version number, because the GitHub releases also contain other releases that are missing the file we actually want.

@crazywhalecc
Copy link
Owner

Linux build failed with a strange linking issue. This error did not appear in the compilation of ICU, but in the link section of compiling PHP.

/usr/bin/ld: /home/jerry/static-php-cli-fork/buildroot/lib/libicuuc.a(udata.ao): in function `doLoadFromCommonData(signed char, char const*, char const*, char const*, char const*, char const*, char const*, char const*, signed char (*)(void*, char const*, char const*, UDataInfo const*), void*, UErrorCode*, UErrorCode*) [clone .constprop.0]':
udata.cpp:(.text._ZL20doLoadFromCommonDataaPKcS0_S0_S0_S0_S0_S0_PFaPvS0_S0_PK9UDataInfoES1_P10UErrorCodeS8_.constprop.0+0x38a): undefined reference to `icudt73_dat'
/usr/bin/ld: udata.cpp:(.text._ZL20doLoadFromCommonDataaPKcS0_S0_S0_S0_S0_S0_PFaPvS0_S0_PK9UDataInfoES1_P10UErrorCodeS8_.constprop.0+0x467): undefined reference to `icudt73_dat'
collect2: error: ld returned 1 exit status

I have attempted to change configure options but still not working.

<?php

declare(strict_types=1);

namespace SPC\builder\linux\library;

class icu extends LinuxLibraryBase
{
    public const NAME = 'icu';

    protected function build()
    {
        $root = BUILD_ROOT_PATH;
        $cppflag = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1  -DU_USING_ICU_NAMESPACE=1  -DU_STATIC_IMPLEMENTATION=1"';
        shell()->cd($this->source_dir . '/source')
            ->exec(
                "{$this->builder->configure_env} {$cppflag} ./runConfigureICU Linux " .
                '--enable-static ' .
                '--disable-shared ' .
                '--with-data-packaging=static ' .
                '--enable-release=yes ' .
                '--enable-extras=yes ' .
                '--enable-icuio=yes ' .
                '--enable-dyload=no ' .
                '--enable-tools=yes ' .
                '--enable-tests=no ' .
                '--enable-samples=no ' .
                "--prefix={$root}"
            )
            ->exec('make clean')
            ->exec("make -j{$this->builder->concurrency}")
            ->exec('make install');
    }
}

PR can be merged now, but only support macOS.

@crazywhalecc
Copy link
Owner

And don't forget sorting config:

bin/spc sort-config ext
bin/spc sort-config lib
bin/spc sort-config source

@crazywhalecc crazywhalecc added the kind/dependency Issues related to dependencies label Jun 2, 2023
@crazywhalecc crazywhalecc added this to the 2.0 robust version milestone Jun 2, 2023
@crazywhalecc
Copy link
Owner

This error has been resolved via Stack Overflow. But a new error has appeared :(

Failed in sanity check: buildroot/bin/php --ri "intl" and after running, the terminal outputs half of the content, and then Aborted.

I checked it, it caused by C++. That means we can only build icu in alpine docker (like swoole).

@mpociot
Copy link
Contributor Author

mpociot commented Jun 2, 2023

Yeah, I just stumbled upon that Stack Overflow answer as well! 👍

Just for my understanding: is it a problem if this can only be built in alpine docker?

Thanks for letting me know about the sort-config commands and for already taking care of it.

@crazywhalecc
Copy link
Owner

crazywhalecc commented Jun 2, 2023

Just for my understanding: is it a problem if this can only be built in alpine docker?

In linux, it is difficult to statically link libraries written in C++, especially when using glibc distributions. Alpine Linux uses musl-libc and its g++ is working well with static compilation (so far, it seems like this).

@crazywhalecc crazywhalecc merged commit f2ef783 into crazywhalecc:refactor Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/dependency Issues related to dependencies
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

intl support
2 participants