apache2 build fails in yocto - "/usr/local/include" is unsafe for cross-compilation [-Wpoison-system-directories] - apache

I was trying to build apache2 on yocto.
But I was getting below errors.
ERROR: This autoconf log indicates errors, it looked at host include and/or library paths while determining system capabilities.
Rerun configure task after fixing this.
Some googling led me to
https://lists.yoctoproject.org/pipermail/yocto/2012-March/005125.html
So I looked into conf.log and find out those lines:
cc1: warning: include location "/usr/local/include" is unsafe for
cross-compilation [-Wpoison-system-directories]
arm-poky-linux-gnueabi/4.9.2/ld: warning: library search path "/usr/local/lib"
is unsafe for cross-compilation
I googled again but, I couldn't understand 3 things yet:
Why has the PATH been set to local path ?
Why does this error only come when building apache2 [ I can build ngnix, cryptsetup, etc..]
How can I fix it?

Usually these types of errors come from configure scripts that have paths (like /usr/local/include, /usr/include and all sorts of other variations) hardcoded into them. So the way to fix it is to patch configure.ac (if there is one in the package, of course, configure otherwise) removing this paths.
For example, take a look at patch for pure-ftpd from current meta-oe, it solves similar problem:
--- a/configure.ac
+++ b/configure.ac
## -100,18 +100,6 ## AC_ARG_VAR(PYTHON,local path to the python interpreter)
python_possible_path="/usr/bin:/usr/local/bin:/bin:/opt/python/bin:/opt/python/usr/bin:/opt/python/usr/local/bin"
AC_PATH_PROG(PYTHON,python,/usr/bin/env python,$python_possible_path)
-if test -d /usr/local/include; then
- CPPFLAGS="$CPPFLAGS -I/usr/local/include"
-fi
-
-if test -d /usr/kerberos/include; then
- CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
-fi
-
-if test -d /usr/local/lib; then
- LDFLAGS="$LDFLAGS -L/usr/local/lib"
-fi
-
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
dnl Checks for header files

Related

How do I compile Tomcat mod_jk on a MacBook Pro M1 chip?

I have Homebrew Apache installed and trying to connect Coldfusion Server 2016 with Tomcat mod_jk.
I downloaded the source code from https://tomcat.apache.org/download-connectors.cgi
I followed the directions to compile it, tried few different ways, but when I get to the "make" command, I keep getting the same error:
In file included from jk_ajp12_worker.c:26:
In file included from ./jk_ajp12_worker.h:26:
In file included from ./jk_logger.h:26:
In file included from ./jk_global.h:340:
./jk_types.h:56:2: error: Can not determine the proper size for pid_t
#error Can not determine the proper size for pid_t
^
./jk_types.h:62:2: error: Can not determine the proper size for pthread_t
#error Can not determine the proper size for pthread_t
^
2 errors generated.
make[1]: *** [jk_ajp12_worker.lo] Error 1
make: *** [all-recursive] Error 1
These are the different commands I've tried to compile:
./configure --with-apxs=/opt/homebrew/bin/apxs
./configure CFLAGS='-arch arm64e' APXSLDFLAGS='-arch arm64e' --with-apxs=/opt/homebrew/bin/apxs
./configure CFLAGS='-arch arm64e' APXSLDFLAGS='-arch arm64e' --with-apxs=/opt/homebrew/bin/apxs --host=arm
I recently got this new MacBook Pro 16" and migrated everything over from my 2017 MacBook Pro (Intel chip). I was running stock Apache with Coldfusion Server 2016, but when I tried to start up Apache on the new MacBook, it didn't like my mod_jk.so file and threw an error:
httpd: Syntax error on line 542 of /opt/homebrew/etc/httpd/httpd.conf: Syntax error on line 2 of /opt/homebrew/etc/httpd/mod_jk.conf:
Cannot load /Applications/ColdFusion2016/config/wsconfig/2/mod_jk.so into server: dlopen(/Applications/ColdFusion2016/config/wsconfig/2/mod_jk.so, 0x000A):
tried: '/Applications/ColdFusion2016/config/wsconfig/2/mod_jk.so'
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
I appreciate any help or input. Thank you.
I've finally installed Apache2 with Tomcat on my M1 and it all works.
The one thing you must do is to install a fresh Apache from Macports or HomeBrew. This is because most old installations copied from your old mac to your new one will now be in the read-only part of your file system and SIP won't let you near them. You will find weird and wonderful workarounds (apachectl told me I had to codesign mod_jk.so for example and I wasted a lot of time doing it and in the end it was pointless) and you will attempt to get the old installation to work, but trust me it's not worth it.
You will need to compile a fresh jk_module (mod_jk.so). This is what I did:
Download latest connector https://dlcdn.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz, save the .gz and unzip it.
Change directory to the native folder.
run which apxs to tell you the path to apxs for the ./configure command
The path mine gave was: /opt/local/bin/apxs. Use it as the path in the ./configure command below.
The commands are as follows (actually don't bother running them yet because they will fail):
./configure --with-apxs=/opt/local/bin/apxs
make
However make will fail with:
./jk_types.h:56:2: error: Can not determine the proper size for pid_t
#error Can not determine the proper size for pid_t
^
./jk_types.h:62:2: error: Can not determine the proper size for pthread_t
#error Can not determine the proper size for pthread_t
^
2 errors generated.
make[1]: *** [jk_ajp12_worker.lo] Error 1
make: *** [all-recursive] Error 1
This is a problem for M1 macs that has been fixed. So for the moment we will abandon the 1.2.48 source and download the source with the fix.
But don't delete the 1.2.48 source because the fix source is missing a few files which you will copy straight over from the 1.2.48 source.
The page to download the fix for Mac OS is here: https://github.com/apache/tomcat-connectors, which is commit e719874 on Jun 30, 2021.
Click on the green 'Code' button and then on 'Download ZIP'.
Unzip the new source and cd to 'native'
Run the commands:
./configure --with-apxs=/opt/local/bin/apxs
make
And whenever it stops and complains that something is missing, find it in the 1.2.48 source and copy it over to the same position in the new source and try again. It will happen two or three times.
I got this error at one point:
/home/myuser/source/mod_auth_cas/mod_auth_cas/missing: line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Error 127
Then I read somewhere to run autoreconf -f -i (which fixed it).
When make finishes, find your nice new mod_jk.so file in the native/apache-2.0 folder and copy it to where all your other modules are. I have a Macports installation so Homebrew is probably different, but my modules are in /opt/local/lib/apache2/modules.
Don't forget to add the LoadModule line in httpd.conf if it isn't already there:
LoadModule jk_module /opt/local/lib/apache2/modules/mod_jk.so
You might have some trouble working out which apache2 folders contain the new install, and not an old installation - I found two other installations knocking about trying to confuse me.
My config is here: /opt/local/etc/apache2/httpd.conf
apachectl is very useful for configuration.
apachectl -t -D DUMP_INCLUDES will find all the configuration files it is using. This totally saved me because it showed me that my httpd.conf file, which I had copied from elsewhere, was still pointing via 'Include' commands at other old config files in the wrong place.
apachectl configtest will test your config for you and print out any mistakes it finds. It pointed at 4 modules that it didn't like so I just excluded them. Though obviously read the messages carefully and google if you are not sure why apachectl doesn't like something. If it replies 'Syntax OK' you are ready to go.
This is a mysterious message I got a lot until I worked out that it was because httpd.conf was pointing at the wrong modules folder (an old install of apache2) for each module, so it was loading stuff that presumably was not compiled for 64bit
httpd: Syntax error on line 76 of /opt/local/etc/apache2/httpd.conf:
Cannot load libexec/apache2/mod_authz_owner.so into server:
dlopen(/usr/libexec/apache2/mod_authz_owner.so, 0x000A): symbol not
found in flat namespace '_apr_stat$INODE64'
This is my launch command using the plist which Macports automatically created:
sudo launchctl load -w /opt/local/etc/LaunchDaemons/org.macports.apache2/org.macports.apache2.plist
And to unload:
sudo launchctl unload /opt/local/etc/LaunchDaemons/org.macports.apache2/org.macports.apache2.plist
run ps ax|grep httpd to see if it's running.
Logging: Don't forget to sudo to create the jk folder in /var/log/apache2 if it doesn't already exist, otherwise apache or tomcat will have mysterious problems or won't start or something (the /var/log/apache2/jk folder is needed for jk.log).
Another problem cropped up just as I thought I had it made: apache
was unable to write its pid file on startup. Again this was because the position set in my config for the pid file was from the configuration on my old mac, and the position chosen was in a read-only location.
To change this you need to set the PidFile parameter, which I found in the following file:
/opt/local/etc/apache2/extra/httpd-mpm.conf
and it looks like this:
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
# Note that this is the default PidFile for most MPMs.
#
<IfModule !mpm_netware_module>
PidFile "local/run/apache2/httpd.pid"
</IfModule>
Don't worry about what the IfModule thing is doing, just set the PidFile to a writeable location, which as you can see is a relative path. You may be wondering what goes in front of the local folder.
What goes in front is the ServerRoot parameter set in httpd.conf:
ServerRoot "/usr"
So my pid will be written at /usr/local/run/apache2/httpd.pid. I had to create the run and apache2 folders.
That's about it. There are various logs that might indicate errors if you are stuck:
/var/log/apache2/error_log
And the jk.log for the apache/tomcat connector:
/var/log/apache2/jk/jk.log
And there's always the system log which just might tell you something:
/var/log/system.log
I hope very much that this helps someone. However it was very long and complicated and I have surely missed something that I did along the way, so if you come across some new problem I will see if I can help.
Running ColdFusion on a Mac is consistently a PITA. Doesn't matter if it's CF 9, 10, 11, all the way to current. Especially when you're dealing with a non-Intel based chipset. You are also trying to get an older and custom build of Toncat running on a chipset that likely isn't supported. You're also not the only one having this issue with CF 2016 on the M1 chip (they didn't find a solution either).
Try using CommandBox to run CF. It will download the server as a JAR file and run it on the Glassfish servlet container (IIRC). You won't need Apache either. It's really quite simple to get up and running.
https://commandbox.ortusbooks.com/embedded-server/multi-engine-support
Once you have it installed, go to your application's root folder in the CLI:
start cfengine=adobe#2016
It will download & install the server, then start the application.
Check the docs for more info.

Apache log4cxx 0.12.0 cmake scripts fail during test configuration

Version: apache-log4cxx-0.12.0.tar.gz
Configuration:
mkdir build; cd build && cmake -DBUILD_SHARED_LIBS=off -DAPR_STATIC=yes -DAPU_STATIC=yes ..
Symptoms (log snippet):
32882 error: downloading 'https://www-us.apache.org/dist/logging/log4j/1.2.17/log4j-1.2.17.tar.gz' failed
32883 status_code: 6
32884 status_string: "Couldn't resolve host name"
32885 log:
32886 --- LOG BEGIN ---
This was building just last month. I can't 100% attest to the fact that the build procedure has not changed (since it was done manually) but I don't believe it was significantly different.
At first, I thought my DNS resolver was just out of date, but after some dig-ing and fiddling with /etc/resolv.conf, it has become apparent that the www-us.apache.org url log4cxx was using to get the tarball from has disappeared from the face of the earth.
Two methods you can use to fix this (which I wish someone had posted before me).
First
Hack your /etc/hosts file to spoof www-us.apache.org to actually go to www.apache.org (where you will find a redirect for the link). To give neophytes an idea of what I'm talking about, here is kinda how I did it on Debian.
sudo echo '151.101.2.132 www-us.apache.org' >> /etc/hosts
Second
Fix the cmake script src/test/java/CMakeLists.txt line 3 to point to the right link. The broken one is
https://www-us.apache.org/dist/logging/log4j/1.2.17/log4j-1.2.17.tar.gz
The right one is
https://downloads.apache.org/logging/log4j/1.2.17/log4j-1.2.17.tar.gz
Digging around the GitHub account we found this code merged and (I assume) ready to go out with the next release, whenever that is.
https://github.com/apache/logging-log4cxx/commit/341a23aa0d13278c8ae85b6017d49de9790f00fe
Here's hoping this helps someone not remain stuck, expecting the build to work like it did a month ago.

Building a kernel module on Centos 7 with a CMake file

Sorry for the length. I have tried to include as much information as possible.
A device I work with randomly fails to start at boot - this is a well known issue with the device and there are lots of posts on the web with no known solution except reboot.
So the task is to look in dmesg for a certain string that if present means the device has failed to start and the system needs rebooting. A simple call to system() with boot seems to do the job.
A unit test that proves this would be nice. The idea is to look for a non-existant uuid in the dmesg log to prove that it fails to find one and then to write a different uuid to the log and then search for that. Proving it works in both cases.
First thing was to hit up google: Find you can write to the kernel log with # echo '<4>Foo: Message' | sudo tee /dev/kmsg which works from terminal but the sudo may cause issue in the unit test.
The next thing I looked at was accessing it via code. The unit tests are written in C++ and the library is googletest.
Most posts talk about writing a Makefile and kbuild. I am working in a build system where we have cmake called from a shell script.
After several hours of searching and trying things, I decided to ask here.
I have installed
kernel.x86_64 3.10.0-1062.el7 #anaconda
kernel.x86_64 3.10.0-1160.21.1.el7 #updates
kernel-devel.x86_64 3.10.0-1160.21.1.el7 #updates
kernel-devel.x86_64 3.10.0-1160.24.1.el7 #updates
kernel-headers.x86_64 3.10.0-1160.21.1.el7 #updates
kernel-tools.x86_64 3.10.0-1160.21.1.el7 #updates
kernel-tools-libs.x86_64 3.10.0-1160.21.1.el7
uname -r gives 3.10.0-1160.21.1.el7.x86_64 which seems to suggest I have the kernel headers and devel files installed.
Doing a find /. -name module.h lists:
...
/usr/src/kernels/3.10.0-1160.24.1.el7.x86_64/arch/x86/include/asm/module.h
/usr/src/kernels/3.10.0-1160.24.1.el7.x86_64/include/asm-generic/module.h
/usr/src/kernels/3.10.0-1160.24.1.el7.x86_64/include/linux/module.h
/usr/src/kernels/3.10.0-1160.24.1.el7.x86_64/include/trace/events/module.h
/usr/src/kernels/3.10.0-1160.24.1.el7.x86_64/include/uapi/linux/module.h
/usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/arch/x86/include/asm/module.h
/usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/asm-generic/module.h
/usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/linux/module.h
/usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/trace/events/module.h
/usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/uapi/linux/module.h
...
It maybe that I am trying to link files in /3.10.0-1160.24.1.el7.x86_64/ when I should be linking to 3.10.0-1160.21.1.el7.x86_64/. Listing installed yum packages via sudo yum list | grep linux-d returns
libselinux-devel.x86_64 2.5-15.el7 #base
libhbalinux-devel.i686 1.0.17-2.el7 base
libhbalinux-devel.x86_64 1.0.17-2.el7 base
libselinux-devel.i686 2.5-15.el7 base
syslinux-devel.x86_64 4.05-15.el7 base
My CMakeFiles.txt looks like
project( X_test )
set( TEST_SOURCE
X_test.cpp
)
execute_process(COMMAND uname -r OUTPUT_VARIABLE uname_r OUTPUT_STRIP_TRAILING_WHITESPACE)
include_directories(/usr/src/kernels/${uname_r}/include)
link_directories(/lib/modules/${uname_r}/build)
add_library(source-lib STATIC source.c)
Anything else in there has been commented out to prevent confusion.
Without the lines include_directories or link_directories I get the error
#include <linux/module.h>
With those lines in I get the error:
In file included from /usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/linux/kernel.h:6:0,
from /usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/linux/cache.h:4,
from /usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/linux/time.h:4,
from /usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/linux/stat.h:18,
from /usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/linux/module.h:10,
from /home/user/git/asdo/Services/DCO-3303/test/source.c:1:
/usr/src/kernels/3.10.0-1160.21.1.el7.x86_64/include/linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory
#include <asm/linkage.h>
The code I am compiling is the standard printk(KERN_INFO "Hello world\n"); which you can see here.
How do I go about compiling code that uses a kernel call through CMake?

Install mozroot-certdata package on a read only root file system

I have an established yocto build which I'm now trying to switch over to having a root file system (eg. EXTRA_IMAGE_FEATURES += "read-only-rootfs").
However I'm running into an issue with a recipe in the meta-mono layer: mozroot-certdata. I see the culprit is the pkg_postint script (http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mozroot-certdata/mozroot-certdata_1.0.0.bb) which needs to modify the root file system on first boot which the build system is correctly flagging as impossible with a read only root file system:
ERROR: The following packages could not be configured offline and rootfs is read-only: ['mozroot-certdata']
My question is: is there a way to get these mozroot certs installed and configured with mono during the build process, such that the root file system does not need to be modified at boot/run time?
Well, I had a brief look at this late this summer, as I'm also using a read-only rootfs. The problem is that mozroot.exe is hardcoded to write into /usr/share/.mono/certs and does not respect your sysroot. You could probably hack mozroot.exe to actually write the imported files into the sysroot, though my time limit didn't allow me to try this (and neither have I ever looked into mono at all...).
My solution was instead to do the import at every boot. (It could also be done only once, but then the issue about updates come along). To achive this I made a bind mount on the directory where mozroot.exe wants to write the certdata.
Details of my solution
Add a file volatile-binds.bbappend with the following contents:
VOLATILE_BINDS += "\
/tmp/mono-certs /usr/share/.mono/certs \n\
"
That will make a bind mount from /tmp/mono-certs to /usr/share/.mono/certs, thus you'll be able to import the certs.
Then I added a service file and a mozroot-certdata_%.bbappend:
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
DEPENDS += "mono-native"
SRC_URI += "file://mozroot-certdata.service \
"
inherit systemd
SYSTEMD_SERVICE_${PN} = "mozroot-certdata.service"
do_install_append() {
mkdir -p ${D}${datadir}/.mono/certs
mkdir -p ${D}${systemd_system_unitdir}
install -m 440 ${WORKDIR}/mozroot-certdata.service ${D}${systemd_system_unitdir}/mozroot-certdata.service
}
FILES_${PN} += "${datadir}"
# Empty the postinstallation script, as we can import the cert offline.
pkg_postinst_${PN} () {
# mono $D/usr/lib/mono/4.5/mozroots.exe --import --machine --ask remove --file $D/${sysconfdir}/ssl/certdata.txt
}
The service file mozroot-certdata.service:
[Unit]
Description=Import certficates to Mono
After=tmp-mono-certs.service
[Service]
Type=oneshot
ExecStart=/usr/bin/mono /usr/lib/mono/4.5/mozroots.exe --import --machine --ask-remove --file /etc/ssl/certdata.txt
[Install]
WantedBy=multi-user.target
is there a way to get these mozroot certs installed and configured with mono during the build process
Yes but it requires mosroots binary to be executable at rootfs creation time. See Post-Installation Scripts in documentation.
The 'else' branch in pkg_postinst is what gets executed at that time and if it succeeds, then the delayed postinst is not needed (and you shouldn't get a build error). mono-native recipe already exists so you should be able to depend on that and to fix the else branch in the pkg_postinst function so it finds native mono & mosroots.exe and writes to the correct place under $D.
As Anders mentioned this alone is not enough if you care about package-based upgrades.

building apache from source on debian

I'm trying to build apache from source on debian. The only reason I'm not using spt-get install is because in the apache cookbook, they recommend installing from source.I get the following error when I ./configure:
configure: error: invalid variable name: ' --with-mpm'
I also saw some warnings when I ./buildconf Is this something I should be concerned about? This is my first attempt at compiling from source, and I'd really appreciate any help.
I'm using the ./configure arguments directly from the apache cookbook:
./configure --prefix=/usr/local/apache --with-layout=Apache --enable-modules=most --enable-mods-shared=all \ --with-mpm=prefork
I'm running a minimum debian install in virtual box to train myself for deploying in the rackspace cloud soon.
EDIT: I'm building Apache 2.2.16
I suspect you are typing that entire build line you provided on one line, complete with the '\' in the middle.
You should get rid of '\', which in bash either treats the following as part of the same string, but the slash has to immediately follow a non-whitespace character. It is also used for special escape sequences, which I think is the case here and generating that message.
This should be the correct line in your case.
./configure --prefix=/usr/local/apache --with-layout=Apache --enable-modules=most --enable-mods-shared=all --with-mpm=prefork
On a side note, doesn't the Apache Cookbook say that building from source is one possibility for installing it, in addition to installing from a pre-packaged build like you can get from Debian's repositories? I suppose if you really wanted a far newer build or a more repeatable process to ensure consistency across a variety of distributions, building from scratch will do that for you, but otherwise I would try to utilize the distribution's package management as much as possible. Building from source removes you from the security patches and ease-of-upgrade path that Debian APT gives you.