Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Build fails on Alpine Linux 3.4.4 because PATH_MAX not defined #1460

Open
aleksijohansson opened this issue Dec 21, 2016 · 5 comments
Open

Comments

@aleksijohansson
Copy link

I'm getting this error while trying to build mod_pagespeed on Alpine Linux 3.4.4:

In file included from third_party/grpc/src/src/core/lib/tsi/transport_security_interface.h:38:0,
                 from third_party/grpc/src/src/core/lib/security/transport/security_connector.h:40,
                 from third_party/grpc/src/src/core/lib/security/credentials/credentials.h:45,
                 from third_party/grpc/src/src/core/lib/surface/init_secure.c:40:
/usr/include/fortify/stdlib.h: In function 'realpath':
/usr/include/fortify/stdlib.h:42:2: error: #error PATH_MAX unset. A fortified realpath will not work.
 #error PATH_MAX unset. A fortified realpath will not work.
  ^
third_party/grpc/grpc_core.target.mk:488: recipe for target 'out/Release/obj.target/grpc_core/third_party/grpc/src/src/core/lib/surface/init_secure.o' failed
make: *** [out/Release/obj.target/grpc_core/third_party/grpc/src/src/core/lib/surface/init_secure.o] Error 1

I see limits.h being included in the third_party/grpc/src/src/core/lib/surface/init_secure.c file, which to my understanding should include PATH_MAX, but I'm not an expert.

@aleksijohansson
Copy link
Author

Any tips to help understand what could be the issue are appreciated! I'm not sure if this is something we could fix on Alpine or simply just some package missing or if this is something we should patch in mod_pagespeed to make it work on Alpine or what.

@ciarans
Copy link

ciarans commented Dec 21, 2016

When I was working on this same issue (which I still have not solved), I came across this: https://bugs.alpinelinux.org/issues/4075. it states the following;

This is due to fortify headers.

Problem is /usr/include/fortify/stdlib.h:

#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#include_next <limits.h>
#endif

#include_next <stdlib.h>

...
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#undef realpath

...

#ifndef PATH_MAX
                __builtin_trap();
#else
                bos = __builtin_object_size(resolved, 0);
                if (PATH_MAX > bos)
                        __builtin_trap();
#endif
To begin, none of _XOPEN_SOURCE, _GNU_SOURCE or _BSD_SOURCE are set, so limits.h is not included.

then is musl libc's stdlib.h included which will pull in features.h, which will set _GNU_SOURCE.

this means that the fortified realpath will be enabled, but with PATH_MAX unset.

PATH_MAX test is compile time, why not #error so we pick it up build time?

We can fix it by change the order, and do #include_next <stdlib.h> before doing conditional #include_next of limits.h.

I downloaded the latest version of fortify-headers, included them as a volume but still got the same error.

Patch info can be found here: http://git.alpinelinux.org/cgit/aports/commit/?id=e7ede9d57ccf4aa6de45cebf2aa24a216537caec

@ciarans
Copy link

ciarans commented Jan 5, 2017

@igrigorik Do you guys have any ideas on this? Otherwise is there a way to disable caching on nginx PageSpeed?

@csandanov
Copy link

Same error with Alpine 3.6 and pagespeed 1.12.34.2

@csandanov
Copy link

I tried to compile with grcp 1.3.0 and 1.4.0 that contains fixes for Alpine (grpc/grpc#10407, grpc/grpc#10800). I got a different error:

 CXX(target) out/Release/obj.target/grpc_cpp/third_party/grpc/src/src/cpp/client/secure_credentials.o
  CXX(target) out/Release/obj.target/grpc_cpp/third_party/grpc/src/src/cpp/common/auth_property_iterator.o
  CXX(target) out/Release/obj.target/grpc_cpp/third_party/grpc/src/src/cpp/common/secure_auth_context.o
  CXX(target) out/Release/obj.target/grpc_cpp/third_party/grpc/src/src/cpp/common/secure_channel_arguments.o
  CXX(target) out/Release/obj.target/grpc_cpp/third_party/grpc/src/src/cpp/common/secure_create_auth_context.o
  CXX(target) out/Release/obj.target/grpc_cpp/third_party/grpc/src/src/cpp/server/secure_server_credentials.o
make: *** No rule to make target 'out/Release/obj.target/grpc_cpp/third_party/grpc/src/src/cpp/client/channel.o', needed by 'out/Release/obj.target/third_party/grpc/libgrpc_cpp.a'.  Stop.

So it seems something should be changed to support new grpc version. We could cherry-pick these changes to 1.2.0 but I don't think this is the best option.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants