Skip to content

Conversation

@randall
Copy link
Contributor

@randall randall commented May 5, 2021

These changes allow for CompileParseRules to be built and run on host
architecture along with cleaning up automake macros that previously
prevented cross-compilation

@randall randall self-assigned this May 5, 2021
@randall randall added this to the 10.0.0 milestone May 5, 2021
@randall randall added the Build work related to build configuration or environment label May 5, 2021
@randall
Copy link
Contributor Author

randall commented May 5, 2021

my testing consisted of cross-compiling on x86_64 macOS targeting arm64.

To test targeting arm64 macOS on x86_64 host, you'll need to build OpenSSL and PCRE (at minimum). I installed my dependencies under /opt/arm64

For PCRE:

CFLAGS='-target arm64-apple-macos'; export CFLAGS
CPPFLAGS='-target arm64-apple-macos'; export CPPFLAGS
CXXFLAGS='-target arm64-apple-macos'; export CXXFLAGS
LDFLAGS='-target arm64-apple-macos'; export LDFLAGS
CC=clang; export CC
CXX=clang++; export CXX
./configure \
--prefix=/opt/arm64 \
--host=x86_64-apple-darwin \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-cpp \
--enable-shared=no
make && make install

For OpenSSL:

./Configure --prefix=/opt/arm64 darwin64-arm64-cc 
make && make install

The environment vars I set along with the host value in testing:

CFLAGS='-target arm64-apple-macos'; export CFLAGS
CXXFLAGS='-target arm64-apple-macos'; export CXXFLAGS
CPPFLAGS="-target arm64-apple-macos -I/opt/arm64/include"; export CPPFLAGS
LDFLAGS="-target arm64-apple-macos -L/opt/arm64/lib"; export LDFLAGS
AM_LDFLAGS="-Xcompiler -target -Xcompiler arm64-apple-macos"; export AM_LDFLAGS
CC=clang; export CC
CXX=clang++; export CXX
./configure \
--host=x86_64-apple-darwin \
--with-openssl=/opt/arm64 \
--with-pcre=/opt/arm64

(I'm not saying those are required, I just tested with those).

This might've addressed some of the issues described in #7754

@randall randall changed the title Enables crosscompling of ATS Enables cross-compiling May 5, 2021
@ywkaras ywkaras requested a review from bneradt May 6, 2021 16:35
@randall randall force-pushed the enable_cross_compile branch 3 times, most recently from 518728c to 2612407 Compare May 10, 2021 01:06
@bryancall
Copy link
Contributor

I am getting this error when running configure:

configure:7756: checking whether the C compiler works
configure:7778: clang -target arm64-apple-macos -target arm64-apple-macos -I/opt/arm64/include -target arm64-apple-macos -L/opt/arm64/lib conftest.c  >&5
ld: warning: directory not found for option '-L/opt/arm64/lib'
ld: warning: ignoring file /Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.osx.a, missing required architecture arm64 in file /Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.osx.a (3 slices)
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture arm64 in file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
ld: dynamic main executables must link with libSystem.dylib for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:7782: $? = 1
configure:7822: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Apache Traffic Server"
| #define PACKAGE_TARNAME "trafficserver"
| #define PACKAGE_VERSION "10.0.0"
| #define PACKAGE_STRING "Apache Traffic Server 10.0.0"
| #define PACKAGE_BUGREPORT "dev@trafficserver.apache.org"
| #define PACKAGE_URL "https://trafficserver.apache.org"
| #define PACKAGE "trafficserver"
| #define VERSION "10.0.0"
| #define HAS_CURL 1
| /* end confdefs.h.  */
|
| int
| main (void)
| {
|
|   ;
|   return 0;
| }
configure:7827: error: in `/Users/bcall/dev/apache/trafficserver/build-Darwin':
configure:7829: error: C compiler cannot create executables
See `config.log' for more details

@bryancall
Copy link
Contributor

I will take a look at this again.

@randall randall force-pushed the enable_cross_compile branch 3 times, most recently from 1aef416 to d5b9929 Compare July 20, 2021 16:36
These changes allow for CompileParseRules to be built and run on host
architecture along with cleaning up automake macros that previously
prevented crosscompliation
@randall randall force-pushed the enable_cross_compile branch from d5b9929 to 624ad51 Compare July 20, 2021 17:08
EXEEXT_FOR_BUILD=""
test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
fi
AC_SUBST(EXEEXT_FOR_BUILD)])dnl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for the trailing "dnl"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@SolidWallOfCode SolidWallOfCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This builds cleanly for me.

@randall
Copy link
Contributor Author

randall commented Oct 14, 2021

[approve ci]

@randall randall merged commit 852d90d into apache:master Oct 14, 2021
@randall randall deleted the enable_cross_compile branch October 14, 2021 18:17
zwoop pushed a commit that referenced this pull request Feb 22, 2022
These changes allow for CompileParseRules to be built and run on host
architecture along with cleaning up automake macros that previously
prevented crosscompliation

(cherry picked from commit 852d90d)
@zwoop
Copy link
Contributor

zwoop commented Feb 22, 2022

Cherry-picked to v9.2.x

@zwoop zwoop modified the milestones: 10.0.0, 9.2.0 Feb 22, 2022
moonchen pushed a commit to moonchen/trafficserver that referenced this pull request Mar 17, 2022
* asf/9.2.x:
  Updated ChangeLog
  Updated ChangeLog
  Fix missing unique_lock definition. (apache#8680)
  Enables crosscompling of ATS (apache#7786)
  Fix test_QUIC unit test builds. (apache#8678) (apache#8691)
  Fix Clang 13.0.1 and GCC 12.0.1 Compiler Warnings (apache#8690)
  url_sig: fix bad cast to pointer of different type (apache#8505)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build work related to build configuration or environment New Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants