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

suggestion about compile.md #601

Open
rust17 opened this issue Feb 26, 2024 · 4 comments
Open

suggestion about compile.md #601

rust17 opened this issue Feb 26, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@rust17
Copy link

rust17 commented Feb 26, 2024

Describe you feature request

Is your feature request related to a problem? Please describe.
When I have multiple versions of PHP installed (php7.4, php8.1, php8.3), I execute the run command:

CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go run .

It prompts:

# github.com/dunglas/frankenphp/caddy/frankenphp
/home/circle/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.linux-amd64/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lphp
collect2: error: ld returned 1 exit status

Describe the solution you'd like
This error indicates that the ld encountered a problem when trying to link the libphp library. After I changed it to this, the program can run:

CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) -L/usr/local/php8.3/lib -lphp $(php-config --libs)" go run . run

Should this be written into compile.md?

@rust17 rust17 added the enhancement New feature or request label Feb 26, 2024
@withinboredom
Copy link
Collaborator

While FrankenPHP will run with non-thread-safe builds of php, I suspect it will act in surprising ways. I assume that is what you mean by "multiple versions of php installed"?

FrankenPHP uses threads instead of a process model and should be built against a thread-safe version of php or it might result in memory corruption and/or sharing data between threads that shouldn't be shared (like session data).

@rust17
Copy link
Author

rust17 commented Feb 27, 2024

While FrankenPHP will run with non-thread-safe builds of php, I suspect it will act in surprising ways. I assume that is what you mean by "multiple versions of php installed"?

FrankenPHP uses threads instead of a process model and should be built against a thread-safe version of php or it might result in memory corruption and/or sharing data between threads that shouldn't be shared (like session data).

I believe the issue might be connected to the method I used to install PHP. I installed multiple versions of php, each with a specified prefix. For instance, PHP 8.3 was installed with the prefix --prefix=/usr/local/php8.3, and PHP 8.1 with --prefix=/usr/local/php8.1. According to the php-src sapi documentation, the command php-config --libs doesn't return lphp, so the linker uncertain about which library to link to:

$ php-config --libs

outputs:

-lresolv -lrt -lutil -lrt -lm -ldl -lpthread -lxml2 -lssl -lcrypto -lsqlite3 -lz -lcurl -lxml2 -lz -lpng16 -lz -lwebp -ljpeg -lfreetype -lonig -lsqlite3 -lxml2 -lxml2 -lxml2 -lxml2 -lzip -lz -lssl -lcrypto

This might be the root cause of the problem.

@withinboredom
Copy link
Collaborator

php-config is also unprefixed, so it points to the last version of php you installed (IIRC). I'm not near a computer today to verify that, but I've run into a similar issue at some point.

@rust17
Copy link
Author

rust17 commented Feb 27, 2024

Sorry, forget about the context earlier. I use source ./profile to set the php version, the php-config corresponds to the same version as the php itself. By the way, this is not urgent, no need for a rush response.
image

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants