* Setting up toolchains
@ 2021-09-27 11:27 Anthony Webber
2021-09-27 14:27 ` Lee
2021-09-27 21:06 ` Hans-Bernhard Bröker
0 siblings, 2 replies; 4+ messages in thread
From: Anthony Webber @ 2021-09-27 11:27 UTC (permalink / raw)
To: cygwin
Please excuse the naivety of this question, but I've looked elsewhere
and can't find a good answer. Perhaps a good answer is to install MSYS2
alongside Cygwin.
Anyway, I am trying to set up my gcc toolchains in Cygwin, by which I
mean that I'm trying to set up the environment so that the right
programs are called at the right time by build systems like cmake and
waf, or if I want to build in a more manual fashion. Particularly, I
want to be able to switch between toolchains easily.
I have installed both the x86_64-pc-cygwin-gcc/g++ and
x86_64-w64-mingw32-gcc/g++ packages using setup-x86_64.exe.
The first thing I notice is that the gcc/g++ programs in /bin are
identical to x86_64-pc-cygwin-gcc/g++, and that symbolic links aren't
being used. I presume it's being done this way because this is
considered the default, native Cygwin toolchain, and that there should
be be relatively little to do in the way of configuration if I want to
build Cygwin software.
If I do want to cross-compile using x86_64-w64-mingw32-gcc/g++, then I
imagine that the very least I should do is set a bunch of environment
variables like CC and CXX (perhaps by sourcing a shell script), but
really I'd like some advice here. What do you guys do?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Setting up toolchains
2021-09-27 11:27 Setting up toolchains Anthony Webber
@ 2021-09-27 14:27 ` Lee
2021-09-27 17:10 ` Brian Inglis
2021-09-27 21:06 ` Hans-Bernhard Bröker
1 sibling, 1 reply; 4+ messages in thread
From: Lee @ 2021-09-27 14:27 UTC (permalink / raw)
To: Anthony Webber; +Cc: cygwin
On 9/27/21, Anthony Webber wrote:
> Please excuse the naivety of this question, but I've looked elsewhere
> and can't find a good answer. Perhaps a good answer is to install MSYS2
> alongside Cygwin.
that seems to be the usual answer here :(
> Anyway, I am trying to set up my gcc toolchains in Cygwin, by which I
> mean that I'm trying to set up the environment so that the right
> programs are called at the right time by build systems like cmake and
> waf,
cmake supposedly supports cross-compilation. I've never figured out
how to do it :(
> or if I want to build in a more manual fashion. Particularly, I
> want to be able to switch between toolchains easily.
GNU autoconf. Switching between toolchains is as easy as
autoconf
autoheader
./configure --host=i686-w64-mingw32
> I have installed both the x86_64-pc-cygwin-gcc/g++ and
> x86_64-w64-mingw32-gcc/g++ packages using setup-x86_64.exe.
>
> The first thing I notice is that the gcc/g++ programs in /bin are
> identical to x86_64-pc-cygwin-gcc/g++, and that symbolic links aren't
> being used. I presume it's being done this way because this is
> considered the default, native Cygwin toolchain, and that there should
> be be relatively little to do in the way of configuration if I want to
> build Cygwin software.
>
> If I do want to cross-compile using x86_64-w64-mingw32-gcc/g++, then I
> imagine that the very least I should do is set a bunch of environment
> variables like CC and CXX (perhaps by sourcing a shell script), but
> really I'd like some advice here. What do you guys do?
I've never written anything that needed a make file; I just use the
correct compiler. eg
$ tail -3 getenv.c
}
/* i686-w64-mingw32-gcc -o getenv.exe getenv.c
*/
The only time I've had to use environment variables was for building mbedtls:
export WINDOWS_BUILD=1
# build for a Windows platform
export SHARED=1
# want the shared libraries created
export CC=i686-w64-mingw32-gcc
export LD=i686-w64-mingw32-gcc
export CFLAGS="-O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2"
export LDFLAGS="${LDFLAGS} -fstack-protector-strong"
make lib
# build the libraries
PATH="${PWD}/library:/usr/i686-w64-mingw32/sys-root/mingw/bin:${PATH}"
# so the tests are able to find the mbedtls and mingw libraries
make check
# run the test suite
Regards,
Lee
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Setting up toolchains
2021-09-27 14:27 ` Lee
@ 2021-09-27 17:10 ` Brian Inglis
0 siblings, 0 replies; 4+ messages in thread
From: Brian Inglis @ 2021-09-27 17:10 UTC (permalink / raw)
To: cygwin
On 2021-09-27 08:27, Lee via Cygwin wrote:
> On 9/27/21, Anthony Webber wrote:
>> Please excuse the naivety of this question, but I've looked elsewhere
>> and can't find a good answer. Perhaps a good answer is to install MSYS2
>> alongside Cygwin.
>
> that seems to be the usual answer here :(
>
>> Anyway, I am trying to set up my gcc toolchains in Cygwin, by which I
>> mean that I'm trying to set up the environment so that the right
>> programs are called at the right time by build systems like cmake and
>> waf,
>
> cmake supposedly supports cross-compilation. I've never figured out
> how to do it :(
>
>> or if I want to build in a more manual fashion. Particularly, I
>> want to be able to switch between toolchains easily.
>
> GNU autoconf. Switching between toolchains is as easy as
>
> autoconf
> autoheader
> ./configure --host=i686-w64-mingw32
>
>
>> I have installed both the x86_64-pc-cygwin-gcc/g++ and
>> x86_64-w64-mingw32-gcc/g++ packages using setup-x86_64.exe.
>>
>> The first thing I notice is that the gcc/g++ programs in /bin are
>> identical to x86_64-pc-cygwin-gcc/g++, and that symbolic links aren't
>> being used. I presume it's being done this way because this is
>> considered the default, native Cygwin toolchain, and that there should
>> be be relatively little to do in the way of configuration if I want to
>> build Cygwin software.
>>
>> If I do want to cross-compile using x86_64-w64-mingw32-gcc/g++, then I
>> imagine that the very least I should do is set a bunch of environment
>> variables like CC and CXX (perhaps by sourcing a shell script), but
>> really I'd like some advice here. What do you guys do?
>
> I've never written anything that needed a make file; I just use the
> correct compiler. eg
>
> $ tail -3 getenv.c
> }
> /* i686-w64-mingw32-gcc -o getenv.exe getenv.c
> */
>
> The only time I've had to use environment variables was for building mbedtls:
>
> export WINDOWS_BUILD=1
> # build for a Windows platform
>
> export SHARED=1
> # want the shared libraries created
>
> export CC=i686-w64-mingw32-gcc
> export LD=i686-w64-mingw32-gcc
> export CFLAGS="-O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2"
> export LDFLAGS="${LDFLAGS} -fstack-protector-strong"
>
> make lib
> # build the libraries
>
> PATH="${PWD}/library:/usr/i686-w64-mingw32/sys-root/mingw/bin:${PATH}"
> # so the tests are able to find the mbedtls and mingw libraries
>
> make check
> # run the test suite
Install cygport and learn the concepts from the html docs, about helper
"cygclasses" which DTRT with definitions or provide them for you,
functions, which you may override with your own shell functions, and
examples available under:
https://cygwin.com/git-cygwin-packages/
which contains over a decade of cygport build control shell script
definitions, patches, and the minimum of everything needed to build many
of the latest Cygwin packages.
That includes cross-builds of cygwin32-, cygwin64-, mingw64-i686-, and
mingw64-x86_64- versions packages.
Beware of the playground branches used to try out CI builds of test and
prerelease versions which may not configure, build, run, or pass any tests.
You can also download the complete source packages which include the
cygport and other build artifacts.
You will always have to install various ...-devel and lib...-devel
packages required to build libraries and programs.
Recently updated cygport script definitions include DEPEND now
BUILD_REQUIRES which define all packages required for building which
have to be installed before running cygport, and by CI jobs at the start
of CI cygport builds.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Setting up toolchains
2021-09-27 11:27 Setting up toolchains Anthony Webber
2021-09-27 14:27 ` Lee
@ 2021-09-27 21:06 ` Hans-Bernhard Bröker
1 sibling, 0 replies; 4+ messages in thread
From: Hans-Bernhard Bröker @ 2021-09-27 21:06 UTC (permalink / raw)
To: cygwin
Am 27.09.2021 um 13:27 schrieb Anthony Webber:
> Anyway, I am trying to set up my gcc toolchains in Cygwin, by which I
> mean that I'm trying to set up the environment so that the right
> programs are called at the right time by build systems like cmake and
> waf, or if I want to build in a more manual fashion. Particularly, I
> want to be able to switch between toolchains easily.
That's hardly ever a question of "setting up" the toolchains. It's
rather a question of
a) which build system those programs you're trying to build uses, and
b) how you initialize/use said build systems.
GNU autoconf and cmake have relatively mature mechanisms for doing this.
For autoconf you just pass --host=... to configure, and that takes care
of everything (assuming the package is capable of cross-building in the
first place). For cmake you can preload a cmake script like this:
cmake -C some/where/preload_mingw.cmake ../../path/to/source
where preload_mingw.cmake might look like this:
set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++" CACHE FILEPATH
"CXX compiler")
set(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc" CACHE FILEPATH "C
compiler")
set(CMAKE_CXX_FLAGS "-D_WIN32_WINNT=0x0601" CACHE STRING "")
set(CMAKE_C_FLAGS "-D_WIN32_WINNT=0x0601" CACHE STRING "")
set(WIN32 "1" CACHE STRING "")
The benefit of doing it this way is that the preload script can stay the
same for quite a lot of packages, and the system default compiler does
not even enter the picture, so there will be no misled tests.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-27 21:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 11:27 Setting up toolchains Anthony Webber
2021-09-27 14:27 ` Lee
2021-09-27 17:10 ` Brian Inglis
2021-09-27 21:06 ` Hans-Bernhard Bröker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).