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

Cross-compiling lwan #154

Closed
fischermario opened this issue Jun 22, 2016 · 3 comments
Closed

Cross-compiling lwan #154

fischermario opened this issue Jun 22, 2016 · 3 comments

Comments

@fischermario
Copy link

fischermario commented Jun 22, 2016

I wanted to use lwan to create a small footprint REST API for a PLC. Unfortunately I came across a few obstacles when trying to cross-compile lwan using GCC 4.8 for the target system (ARMv7/Cortex-A8 based):

  1. mimegen: it is built first to run on the host system. Unfortunately cmake cannot differentiate between targets for the host system and targets to be cross-compiled. I came up with a way to do this without hurting the build process on regular systems.
  2. The compiler flag "-mtune=native" does not sit well with some (not all!) ARM systems. I have added a condition to only set the flag on x86_64.
  3. Compiling common/hash.c produces the following error message (paths omitted):
    [ 50%] Building C object common/hash.c.o common/hash.c: In function 'get_random_unsigned': common/hash.c:74:32: error: 'O_CLOEXEC' undeclared (first use in this function)
    There is a simple fix for that (references: GitHub bugreport, blog post).

I have attached a patch to deal with the issues described above:
lwan-crosscompile.patch.txt

@lpereira
Copy link
Owner

Nice!

I imagined that mimegen becoming a native program rather than a Python script would be a problem for cross-compiling. Thanks for fixing this.

As for the mtune parameter, is there any way to detect if it's not going to work with a particular processor family, or is that more of a cross-compilation issue?

If the stuff you're building is open source, send me a link once Lwan is part of it so I can link to it from the readme file.

I'll test the patch as soon as I'm in front of a computer.

@fischermario
Copy link
Author

fischermario commented Jun 22, 2016

As for the mtune parameter, is there any way to detect if it's not going to work with a particular processor family, or is that more of a cross-compilation issue?

You are right. It is better to check whether the compiler supports this particular parameter or not.

The following patch assumes that you have already applied the former:
mtune-detection.patch.txt

If the stuff you're building is open source, send me a link once Lwan is part of it so I can link to it from the readme file.

You are giving me too much credit ;-) My tool is just in its infancy. Right now I am playing around with Lwan, getting used to it, reading the example code. I already hit some walls. Lwan is a great piece of software, but it is in dire need of a proper documentation.

@lpereira
Copy link
Owner

Nice, I'll use the new patch as well.

As for hitting walls: please don't hesitate to either open issues or send me emails. That'll help me to know what to focus whenever I start writing the documentation.

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

No branches or pull requests

2 participants