-
Notifications
You must be signed in to change notification settings - Fork 445
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-Compilation (linux to MinGW 64) #509
Conversation
obviously not worrying about a clean makefile rn, just trying to get it to work at all first |
|
Removed the @AndrewBelt could we have a separate |
Cross compiled .dll works with downloaded Rack! |
Hey @s-ol - this is excellent work. What I'd really love is if we could make a Docker image so that anybody can easily and automatically cross compile for different architectures. Any chance you'd be able to make a Docker image for your work? |
@Miserlou working on it. IMO docker images are a bit overhyped for this kind of thing but the Dockerfile will be a good reference anyway and since some CI can run in an image directly there's some validity there. |
Nice! Yeah, Docker is overhyped but this is a good use case. I'm mostly interested in this for building a build CI for modules, not for Rack itself - related: VCVRack/library#6 |
my god, this was a pain but I finally got glew and glfw to compile cleanly both. Before it was a hack where it was using the headers from the included source and the binary from my arch install, which was hard to reproduce. I think i finally have it building clean from this branch with:
and then plugins build just with make as well.
|
Very nice! Do you want to try to Dockerize everything with cloning the right Rack release and multi-arch builds for plugins? :D |
@Miserlou it is dockerized from the Rack main directory. I don't think its feasible to develop one Dockerfile for multiarch publishing, it makes more sense to have separate ones because then the Rack dependencies can be preinstalled in the image, not built at (docker-)runtime. I have just managed to cross-compile Rack (minus the core modules) in docker for the first time. Here's my Dockerfile: FROM base/devel
RUN pacman -Sy --noconfirm sudo wget unzip
RUN useradd -m notroot && echo "notroot ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/notroot
ADD https://aur.archlinux.org/cgit/aur.git/snapshot/mingw-w64-pkg-config.tar.gz \
https://aur.archlinux.org/cgit/aur.git/snapshot/mingw-w64-cmake.tar.gz \
https://aur.archlinux.org/cgit/aur.git/snapshot/mingw-w64-zlib.tar.gz \
/opt/packages/
RUN cd /opt/packages && for f in *.gz; do tar xf $f; done && chmod -R 777 *
RUN cd /opt/packages/mingw-w64-pkg-config && sudo -u notroot makepkg -si --noconfirm --force
RUN cd /opt/packages/mingw-w64-cmake && sudo -u notroot makepkg -si --noconfirm --force
RUN cd /opt/packages/mingw-w64-zlib && sudo -u notroot makepkg -si --noconfirm --force
COPY . /opt/Rack
WORKDIR /opt/Rack
ENV ARCH=win \
CC=x86_64-w64-mingw32-gcc \
LD=x86_64-w64-mingw32-ld \
AR=x86_64-w64-mingw32-ar \
CXX=x86_64-w64-mingw32-g++ \
CFGFLAGS="--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --enable-shared --enable-static"
RUN make dep SYSTEM=linux-mingw64 CMAKE=x86_64-w64-mingw32-cmake WITHOUT_CORE=1
RUN make WITHOUT_CORE=1
VOLUME /opt/Rack/plugins/plugin
WORKDIR /opt/Rack/plugins/plugin
ENTRYPOINT ["make"]
CMD ["dist"] I will push the image to
Unforunately i'm out of time for today, please do test and report back your findings. I won't check in the Dockerfile to this branch because I don't believe it belongs into VCVRack's top level and otherwise this branch is clean and, IMO, strictly relevant for an actual merge (what do you think @AndrewBelt?). |
Woho! Dang, this is huge. Will try to experiment with this ASAP. |
@Miserlou hm, glew is breaking in the docker build still (means I can't push). Don't have any more time today but after spending the last two days on this I'll be damned if that's not solve-able. |
so much for no more attempts but.... IT WORKS! FROM base/devel
RUN pacman -Sy --noconfirm sudo wget zip unzip
RUN useradd -m notroot && echo "notroot ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/notroot
ADD https://aur.archlinux.org/cgit/aur.git/snapshot/mingw-w64-pkg-config.tar.gz \
https://aur.archlinux.org/cgit/aur.git/snapshot/mingw-w64-cmake.tar.gz \
https://aur.archlinux.org/cgit/aur.git/snapshot/mingw-w64-zlib.tar.gz \
/opt/packages/
RUN cd /opt/packages && for f in *.gz; do tar xf $f; done && chmod -R 777 *
RUN cd /opt/packages/mingw-w64-pkg-config && sudo -u notroot makepkg -si --noconfirm --force
RUN cd /opt/packages/mingw-w64-cmake && sudo -u notroot makepkg -si --noconfirm --force
RUN cd /opt/packages/mingw-w64-zlib && sudo -u notroot makepkg -si --noconfirm --force
COPY . /opt/Rack
WORKDIR /opt/Rack
RUN make dep \
ARCH=win \
SYSTEM=linux-mingw64 \
CC=x86_64-w64-mingw32-gcc \
LD=x86_64-w64-mingw32-ld \
AR=x86_64-w64-mingw32-ar \
CXX=x86_64-w64-mingw32-g++ \
CMAKE=x86_64-w64-mingw32-cmake \
CFGFLAGS="--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --enable-shared --enable-static" \
WITHOUT_CORE=1
RUN make \
ARCH=win \
LD=x86_64-w64-mingw32-ld \
CC=x86_64-w64-mingw32-gcc \
CXX=x86_64-w64-mingw32-g++ \
WITHOUT_CORE=1
VOLUME /opt/Rack/plugins/plugin
WORKDIR /opt/Rack/plugins/plugin
ENTRYPOINT [ "make", \
"ARCH=win", \
"LD=x86_64-w64-mingw32-ld", \
"CC=x86_64-w64-mingw32-gcc", \
"CXX=x86_64-w64-mingw32-g++" \
]
CMD ["dist"]
The image is up too now. |
Very nice! It's working for me, and some of my files compile, but now I'm facing what might be a more annoying problem: code written for Awesome, awesome work - I bet this is going to save a lot of people a lot of effort, and hopefully mean that we get lots more modules for lots more platforms. |
@Miserlou I don't have experience with that since I've been using gcc always. What exactly have you been having problems with? In the end you should theoretically stick to a C++ standard and then your code is supposed to be compiler-safe. Rack itself is c++11 so sticking to that would be a good idea. |
Please excuse the possibly noobish question, but what does "dockerizing" VCV Rack or it's plugins buy us? To me Docker = Cloud, and VCV Rack (again, to me) is a desktop application. Thanks in advance for your reply! |
The application wouldn't run inside of Docker - we would just build a small Docker image (or images) with all of the necessary toolchains required to build a module on each of the target platforms, as getting this stuff installed and configured for every module developer is the hardest part, and the reason we don't have all modules for all platforms. |
@dbradee exactly, as @Miserlou said we are dockerizing the/a build environment to gurantee easy setup of fresh builds. Also note that docker is not really related to cloud things, it is simply a tool to sandbox processes in their own tiny operating sysstems and to describe those images/containers etc. This comes in very handily when you want to run and maintain various different services (databases, webservers, ...) as in a cloud environment, but there are many valid use cases (such as this). With some X11 trickery I'm pretty sure you can even run a GUI app like VCVRack from inside docker and have it render to your native desktop (why you would want to do this is a good question and is what i guess you were getting at originally) |
With the Rack SDK at https://github.com/VCVRack/Rack/issues/258#issuecomment-376293898, all you need now is mingw. Download it and run
to build your plugins. On Mac:
Surprisingly, building on Linux from Linux requires Docker because I can't figure out how to compile and link against glibc 2.23 on newer versions of GCC. Anyone want to research a way to do this? |
(This is WIP and for documenting progress so far)
I am running arch and installed these packages:
Compiling deps:
can't get GLEW to work but seems to link against mingw-w64-glew package
rtaudio and rtmidi also fail in random ways
rest can be built using:
(possibly needs
PATH=/usr/x86_64-w64-mingw32/bin/:$PATH
)