You are not logged in.

#1 2021-02-09 22:35:43

rekubeku
Member
Registered: 2021-02-09
Posts: 2

How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

While installing PHP 7.1 using YAY I'm getting this error: ‘TRUE’ undeclared
The output of `pacman -Qs icu`

local/harfbuzz-icu 2.7.4-1
    OpenType text shaping engine (ICU integration)
local/icu 68.2-1
    International Components for Unicode library
local/lib32-icu 68.2-1
    International Components for Unicode library (32 bit)

Note: installing/updating PHP 7.2 and 7.4 works for me
is there a way to install PHP 7.1 and still be able to upgrade other versions that are currently working?

(noob friendly please)

Offline

#2 2021-02-09 23:14:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

What does that pacman output have to do with anything?  Post the complete output from the command that's failing.  Also first build with makepkg - if that gives an error post it here.

EDIT: I can replicate the problem.  The error is during the build and it's just bad code from the upstream source:

/tmp/php71/src/php-7.1.33/ext/intl/collator/collator_sort.c: In function ‘zif_collator_sort’:
/tmp/php71/src/php-7.1.33/ext/intl/collator/collator_sort.c:349:26: error: ‘TRUE’ undeclared (first use in this function)
  349 |  collator_sort_internal( TRUE, INTERNAL_FUNCTION_PARAM_PASSTHRU );
      |                          ^~~~
/tmp/php71/src/php-7.1.33/ext/intl/collator/collator_sort.c:349:26: note: each undeclared identifier is reported only once for each function it appears in
/tmp/php71/src/php-7.1.33/ext/intl/collator/collator_sort.c: In function ‘zif_collator_asort’:
/tmp/php71/src/php-7.1.33/ext/intl/collator/collator_sort.c:543:26: error: ‘FALSE’ undeclared (first use in this function)
  543 |  collator_sort_internal( FALSE, INTERNAL_FUNCTION_PARAM_PASSTHRU );
      |                          ^~~~~
make: *** [Makefile:1136: ext/intl/collator/collator_sort.lo] Error 1
make: *** Waiting for unfinished jobs....
==> ERROR: A failure occurred in build().
    Aborting...

I suspect simply replacing those with true and false might work, otherwise just define them as 1 and 0.

EDIT: now I see what ICU has to do with this - there are comments on the AUR page for php71 trying to blame this on an ICU change.  But that's nonsense.  The upstream code assuming nonstandard macros will be defined when they didn't define or check for themselves is the problem.

EDIT 2: This fix worked, in a sed line in the PKGBUILD, but the error popped up on other source files - it seems a pervasive issue in the code.  So just add definitions of TRUE and FALSE to CFLAGS ... or not - F*** Me that's annoying, the makefile ignores CFLAGS settings.  It looks like one might be able to set "EXTRA_CFLAGS" - I'm trying that now.

Last edited by Trilby (2021-02-09 23:40:53)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#3 2021-02-09 23:27:35

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

Moving to AUR issues.

Offline

#4 2021-02-10 00:17:15

loqs
Member
Registered: 2014-03-06
Posts: 17,323

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

https://bugs.php.net/bug.php?id=80310 but I can not get the fix to work.

Adding DU_DEFINE_FALSE_AND_TRUE=1 to INTL_COMMON_FLAGS worked are ICU_CXXFLAGS being ignored?

diff --git a/configure b/configure
index 78811fa..5a303a0 100755
--- a/configure
+++ b/configure
@@ -45864,7 +45864,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
     php_cxx_done=yes
   fi
 
-  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
+  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DU_DEFINE_FALSE_AND_TRUE=1"
   if test "$icu_version" -ge "4002"; then
     icu_spoof_src=" spoofchecker/spoofchecker_class.c \
     spoofchecker/spoofchecker.c\

Offline

#5 2021-02-10 00:29:25

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

The above sounds much better - but I had been trying all sorts of things that *should* have worked that didn't until I came up with the very ugly but functional hack below:

build() {
	export CC="gcc -DTRUE=1 -DFALSE=0"
	export CXX="g++ -DTRUE=1 -DFALSE=0"
    local phpConfig="\
        --srcdir=../${_pkgbase}-${pkgver} \
        --config-cache \

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#6 2021-02-10 10:30:05

rekubeku
Member
Registered: 2021-02-09
Posts: 2

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

Trilby wrote:

The above sounds much better - but I had been trying all sorts of things that *should* have worked that didn't until I came up with the very ugly but functional hack below:

build() {
	export CC="gcc -DTRUE=1 -DFALSE=0"
	export CXX="g++ -DTRUE=1 -DFALSE=0"
    local phpConfig="\
        --srcdir=../${_pkgbase}-${pkgver} \
        --config-cache \

Thanks @Trilby, this worked for me. Will link this thread to PHP71 AUR page as well.

Last edited by rekubeku (2021-02-10 10:39:38)

Offline

#7 2021-02-10 10:58:44

Flowcki
Member
Registered: 2021-02-10
Posts: 1

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

Thank you @reibeku @Trilby for the fix, I had the same issue, but I don't know how to apply the fix during the installation hmm
I'm new with Arch since 1 week ^^

Offline

#8 2021-02-10 15:17:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

Edit the PKGBUILD, and add the lines that are the obvious change from what's already there.  If you haven't read the PKGBUILD, you shouldn't be building it.

But also note that loqs' approach is better, if that works, use that instead.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#9 2021-02-10 17:17:22

loqs
Member
Registered: 2014-03-06
Posts: 17,323

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

Patching_packages#Applying_patches
As noted you can use updpkgsums from pacman-contrib to update the checksum array so you only need to add the patch to the source array and a call to patch in prepare() applying it.
Below shows the diff after applying the patch:

diff --git a/PKGBUILD b/PKGBUILD
index 8aced76..014a7d0 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -54,20 +54,20 @@ source=(
     'php.ini.patch'
     'php-icu-1100-Utilize-the-recommended-way-to-handle-the-icu-namespace.patch'
     'php-icu-1101-Simplify-namespace-access.patch'
+    'php-icu-boolean-fix.patch'
 )
-sha512sums=(
-    'ed37a79e3402c767f20e55c1cbe27957cc78240eafc719fffccd7d29ae10a45112aa0f29082f56133cd9c25f2750e9e57246d95b4f38d766f49bd29d1397eb1d'
-    '022d1fc374dce70209a266b512fbfd2b817a160475d298c970abbd7d9a79be36eb995a9519bbf142f4878df74b29c006c76b589114ebc455de0f3cd07b84f375'
-    'f5e5431993c2e0c1806c4edf392030d0b605f4b3c4cebec036e810ff771b2327983f347221735673506e2c91ce2e18ad37ab7600261b684fe29491206171b4f3'
-    '30cdc281c6e288cf8a0bf58a0ad74ad5b4e8205d2b0b6ab465fad97d810f7bfae4581ad836712998e834d2e90d38cacd22f19bb01e77fc4c9d200d95613fc669'
-    '2d5f3aa71ce7d8da43f0f683f81b06258e3a0d95df4807a8acac91ff89fbe60484ef97856a908bce625b1610d0004767a6a8c622246086afe2f2d464977088b5'
-    'a664b69aea8c21c50c852f918515d9fe1a931d7f88ec77ec86a20810266515745430d89513ee2e0bb301a29f1fc7ab0d2634076830b4da8ea1e47467fb658678'
-    'a23e13180449ace0cfe07e19043615ca7e1dbf254fd24f2446cd2d824728430258ec4140325508169480eaec950ad4737b673417bd70e0f9d4538f1ab3b98816'
-    '48a97ab0cedd92539b8fe4c82e59312b563a73a8ca537b5a1b2091bfd287f255e94a32c2e5398ccfa7248ef322275a15a4edb817bad6ccf430c79d2f9c5cf0e9'
-    'b6ff1c8575c7564ede17ec8c959141a065a9c4e3cba059a1138b9ecc85f23632d7e5980d65742f7fc1ce404ce613f7abb2f5f7a45039d606c9c590ccf3a2301d'
-    '70c859feff58650ff4a291b1725bce8f290ac6d92cacc4420d3ead5cbbdbcf567cd0ed4d79fdd8b0435cf6833f7b50fff798b2fae274c5fb1bb37a0984a45f9d'
-    '33d40f3ae500cf583519ecfa271e36d727c38ff4ea9547d3d2c4d51c9fadd317ed614a048077ebdb116e3c84c11db95e6455cdfc80d092d217d070c98af56525'
-)
+sha512sums=('ed37a79e3402c767f20e55c1cbe27957cc78240eafc719fffccd7d29ae10a45112aa0f29082f56133cd9c25f2750e9e57246d95b4f38d766f49bd29d1397eb1d'
+            'SKIP'
+            'f5e5431993c2e0c1806c4edf392030d0b605f4b3c4cebec036e810ff771b2327983f347221735673506e2c91ce2e18ad37ab7600261b684fe29491206171b4f3'
+            '30cdc281c6e288cf8a0bf58a0ad74ad5b4e8205d2b0b6ab465fad97d810f7bfae4581ad836712998e834d2e90d38cacd22f19bb01e77fc4c9d200d95613fc669'
+            '2d5f3aa71ce7d8da43f0f683f81b06258e3a0d95df4807a8acac91ff89fbe60484ef97856a908bce625b1610d0004767a6a8c622246086afe2f2d464977088b5'
+            'a664b69aea8c21c50c852f918515d9fe1a931d7f88ec77ec86a20810266515745430d89513ee2e0bb301a29f1fc7ab0d2634076830b4da8ea1e47467fb658678'
+            'a23e13180449ace0cfe07e19043615ca7e1dbf254fd24f2446cd2d824728430258ec4140325508169480eaec950ad4737b673417bd70e0f9d4538f1ab3b98816'
+            '48a97ab0cedd92539b8fe4c82e59312b563a73a8ca537b5a1b2091bfd287f255e94a32c2e5398ccfa7248ef322275a15a4edb817bad6ccf430c79d2f9c5cf0e9'
+            'b6ff1c8575c7564ede17ec8c959141a065a9c4e3cba059a1138b9ecc85f23632d7e5980d65742f7fc1ce404ce613f7abb2f5f7a45039d606c9c590ccf3a2301d'
+            '70c859feff58650ff4a291b1725bce8f290ac6d92cacc4420d3ead5cbbdbcf567cd0ed4d79fdd8b0435cf6833f7b50fff798b2fae274c5fb1bb37a0984a45f9d'
+            '33d40f3ae500cf583519ecfa271e36d727c38ff4ea9547d3d2c4d51c9fadd317ed614a048077ebdb116e3c84c11db95e6455cdfc80d092d217d070c98af56525'
+            '759c3752473cc7c768f3622feda0e10307718f6e1f78d0285bd17b3080dcfab581e40a3859b26352f10b442bdf84455b556b2b5bfedde8cea98ba985884c94ba')
 
 validpgpkeys=(
     # PGP keys from PHP maintainer (upstream)
@@ -104,6 +104,7 @@ prepare() {
     patch -p1 -i ../php-icu-1100-Utilize-the-recommended-way-to-handle-the-icu-namespace.patch
     patch -p1 -i ../php-icu-1101-Simplify-namespace-access.patch
     patch -p0 -i ../php.ini.patch
+    patch -p1 -i ../php-icu-boolean-fix.patch
 }
 
 build() {
diff --git a/php-icu-boolean-fix.patch b/php-icu-boolean-fix.patch
new file mode 100644
index 0000000..5b4e769
--- /dev/null
+++ b/php-icu-boolean-fix.patch
@@ -0,0 +1,13 @@
+diff --git a/configure b/configure
+index 78811fa..5a303a0 100755
+--- a/configure
++++ b/configure
+@@ -45864,7 +45864,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+     php_cxx_done=yes
+   fi
+ 
+-  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
++  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DU_DEFINE_FALSE_AND_TRUE=1"
+   if test "$icu_version" -ge "4002"; then
+     icu_spoof_src=" spoofchecker/spoofchecker_class.c \
+     spoofchecker/spoofchecker.c\

Offline

#10 2022-01-07 09:50:46

pratikb
Member
Registered: 2021-10-25
Posts: 4

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

This worked for me

 export CXX="g++ -DTRUE=1 -DFALSE=0"
 export  CC="gcc -DTRUE=1 -DFALSE=0"

https://github.com/phpbrew/phpbrew/issu … -855810143

Offline

#11 2022-01-07 16:23:07

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: How to fix: error: ‘TRUE’ undeclared (installing PHP 7.1)

Using this opportunity to close this old thread.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB