We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5234

Summary: Build fails with autoconf 2.70
Product: SDL Reporter: Ross Burton <ross>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: sezeroz
Version: 2.0.13   
Hardware: All   
OS: All   
Attachments: configure difference before and after patch from comment #2

Description Ross Burton 2020-07-16 16:35:00 UTC
The build fails with autoconf 2.70 (beta1):

| checking for size_t... yes 
| checking for M_PI in math.h... ../SDL2-2.0.12/configure: line 13202: CPP: command not found 
| checking how to run the C preprocessor... gcc  -E 
| ../SDL2-2.0.12/configure: line 13328: ac_fn_c_try_cpp: command not found 
| ../SDL2-2.0.12/configure: line 13328: ac_fn_c_try_cpp: command not found 
| configure: error: in `/home/pokybuild/yocto-worker/qemux86-64/build/build/tmp/work/x86_64-linux/libsdl2-native/2.0.12-r0/build': 
| configure: error: C preprocessor "gcc  -E" fails sanity check 
| See `config.log' for more details 
| WARNING: exit code 1 from a shell command. 

Discussion with autoconf upstream:

---
This is a classic M4 quoting bug.  The macro should quote the third
argument to AC_CACHE_CHECK (and really, should quote all the arguments).

The problem is that diversions do not work properly during arugment
collection so AC_REQUIRE (which depends on diversions) and many other
macros will not work properly if it is expanded during argument
collection.

Quote the arguments to AC_CACHE_CHECK and the prerequisite macros will
get expanded in the correct order.

(also WTF is with that stray AC_DEFINE outside of the macro definition?)
---
Comment 1 Ross Burton 2020-09-03 14:16:46 UTC
Ping.  Autoconf 2.70 is coming out soon and libSDL won't build.
Comment 2 Ozkan Sezer 2020-09-10 16:33:05 UTC
The following fixes this issue for me.  OK to apply?

diff --git a/acinclude/ac_check_define.m4 b/acinclude/ac_check_define.m4
--- a/acinclude/ac_check_define.m4
+++ b/acinclude/ac_check_define.m4
@@ -1,4 +1,4 @@
-AC_DEFUN([AC_CHECK_DEFINE],[dnl
+AC_DEFUN([AC_CHECK_DEFINE],[AC_REQUIRE([AC_PROG_CPP])dnl
   AC_CACHE_CHECK(for $1 in $2, ac_cv_define_$1,
     AC_EGREP_CPP([YES_IS_DEFINED], [
 #include <$2>
Comment 3 Ross Burton 2020-09-10 18:08:06 UTC
The correct fix is to quote the arguments.
Comment 4 Ozkan Sezer 2020-09-10 18:58:35 UTC
(In reply to Ross Burton from comment #3)
> The correct fix is to quote the arguments.

I tried doing that (maybe incompletely or incorrectly)
it still failed.

I suggest that you give us a working patch.
Comment 5 Ozkan Sezer 2020-09-10 20:56:06 UTC
Created attachment 4461 [details]
configure difference before and after patch from comment #2

Also see:
http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob;f=NEWS#l43

The issue might be related to optimizations mentioned in there.
E.g.: without the patch from comment #2, the CPP environment
variable is ignored. So I believe AC_REQUIRE([AC_PROG_CPP]) is
is needed there. (Alternatively, AC_PROG_CPP can be added to
configure.ac .)

Still waiting for your own patch to fix the issue.
Comment 6 Ozkan Sezer 2020-09-16 05:01:31 UTC
Since no one else provided a solution, I pushed the patch
from comment #2:
https://hg.libsdl.org/SDL/rev/2c13b7ca1997

If there is a better solution, attach a proper patch here.