phoenixframework / tailwind

An installer for tailwind
MIT License
475 stars 61 forks source link

Support FreeBSD with bespoke upstream build #71

Closed dch closed 1 year ago

dch commented 1 year ago

We can't use upstream tailwind FreeBSD packages, because the vercel/pkg tool that tailwind relies on builds in github actions, which don't support FreeBSD. Thus we build these externally, and need to make a few modifications to accommodate this.

This is in "Works on my machine" mode presently; we could make further changes from here if interested:

I will generate the build artifacts separately with verifiable checksum shortly, which should improve the trust factor a bit.

Using https://builds.sr.ht/ and this manifest:

This is now the artefact at https://people.freebsd.org/~dch/pub/tailwind/v3.2.4/tailwindcss-freebsd-x64 at least for the moment.

$ curl -#LO https://patchouli.sr.ht/builds.sr.ht/artifacts/~dch/910662/0223ad33fd6373fe/tailwindcss-freebsd-x64
############################################################################## 100.0%
$ l
total 4192
-rw-r--r--  1 dch  devel    44M Dec 23 21:15 tailwindcss-freebsd-x64
$ sha256 *
SHA256 (tailwindcss-freebsd-x64) = d71d4b4c8bf0e4d4bb590e286c892d3d7209640bac3c8c3cfb11aadc7b897694
$ sha512 *
SHA512 (tailwindcss-freebsd-x64) = a5a38f13cf405776f06164af4dbcf8bef9a3d8c256b8d3f90ae6a80ee9a2f0a13931138e86db083e7900664239c844124fc811f2f30ed98e69123905b6136693

Alternative approaches welcomed.

josevalim commented 1 year ago

Hi @dch! Can you please send a PR that adds only the target? Then with #60, you can do: mix tailwind.install custom-url, which should make it easier for people to get it running on other platforms.

dch commented 1 year ago

@josevalim done. It's great to see how #60 turned out, this is the way!

josevalim commented 1 year ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart:

dch commented 1 year ago

:rocket: :star_struck: :ping_pong: :earth_africa: :ocean:

dch@wintermute /p/i/indie> mix tailwind.install https://people.freebsd.org/~dch/pub/tailwind/v3.2.4/tailwindcss-freebsd-x64
dch@wintermute /p/i/indie> l _build/tailwind-freebsd-x64
-rwxr-xr-x  1 dch  wheel    45M Jan 16 14:32 _build/tailwind-freebsd-x64*
dch@wintermute /p/i/indie>
leonardorame commented 1 year ago

Hi!, it seems that my FreeBSD version (13.1) isn´t compatible:

ld-elf.so.1: /usr/local/lib/gcc10/libstdc++.so.6: version GLIBCXX_3.4.30 required by /usr/home/leonardo/desarrollo/phoenix1.7/hello_world/_build/tailwind-freebsd-x64 not found
[info] Running HelloWorldWeb.Endpoint with cowboy 2.9.0 at 127.0.0.1:4000 (http)
ld-elf.so.1: /usr/local/lib/gcc10/libstdc++.so.6: version GLIBCXX_3.4.30 required by /usr/home/leonardo/desarrollo/phoenix1.7/hello_world/_build/tailwind-freebsd-x64 not found
leonardorame commented 1 year ago

Hi again, after spending many hours trying to compile tailwind without success I downloaded the Linux version: https://github.com/tailwindlabs/tailwindcss/releases/download/v3.2.4/tailwindcss-linux-x64, as I have installed linuxulator I can run it from command line without issues, then I copied it as tailwindcss-freebsd-x64 into my webserver (a local Apache24) and did mix tailwind.install http://127.0.0.1/tailwindcss-freebsd-x64, it automatically downloaded and copied into my project's _build directory, but when I run mix phx.server it hangs forever without showing any error.

dch commented 1 year ago

hey @leonardorame I think this will be one of 2 issues:

Using https://people.freebsd.org/~dch/pub/tailwind/v3.2.6/tailwindcss-freebsd-x64

$ chmod +x ./tailwindcss-freebsd-x64
$ ldd ./tailwindcss-freebsd-x64
        libutil.so.9 => /lib/libutil.so.9 (0x1c3cb1d0d000)
        libkvm.so.7 => /lib/libkvm.so.7 (0x1c3cb0e2a000)
        libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x1c3cb247a000)
        libstdc++.so.6 => /usr/local/lib/gcc12/libstdc++.so.6 (0x1c3cb2a00000) <---
        libm.so.5 => /lib/libm.so.5 (0x1c3cb3277000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x1c3cb34ef000)
        libthr.so.3 => /lib/libthr.so.3 (0x1c3cb4aa0000)
        libc.so.7 => /lib/libc.so.7 (0x1c3cb3fb1000)
        libelf.so.2 => /lib/libelf.so.2 (0x1c3cb5593000)
        [vdso] (0x1c3cafa985d0)

For the latter, I need to ask a few people to figure out how this can be accommodated.

leonardorame commented 1 year ago

Hi @dch, yes I'm using quarterly ports and yes, I have gcc9, gcc10, gcc11 and gcc12.

When I run ldd on that file I get this:

tailwindcss-freebsd-x64:
    libutil.so.9 => /lib/libutil.so.9 (0x80303f000)
    libkvm.so.7 => /lib/libkvm.so.7 (0x803057000)
    libexecinfo.so.1 => /usr/lib/libexecinfo.so.1 (0x80306c000)
    libstdc++.so.6 => /usr/local/lib/gcc10/libstdc++.so.6 (0x803072000) <--- gcc10 !
    libm.so.5 => /lib/libm.so.5 (0x803459000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x803494000)
    libthr.so.3 => /lib/libthr.so.3 (0x8034ae000)
    libc.so.7 => /lib/libc.so.7 (0x8034dc000)
    libelf.so.2 => /lib/libelf.so.2 (0x8038e6000)
leonardorame commented 1 year ago

Hi @dch, I created a Jail with latest ports and it worked!.

Now, it should be great if we can find a way to build it with quarterly ports. I think most users use RELEASE, which by default have quarterly ports.

dch commented 1 year ago

@leonardorame try this one, https://builds.sr.ht/~dch/job/950069 via

curl -#L https://patchouli.sr.ht/builds.sr.ht/artifacts/~dch/950069/b55f38667af56331/tailwindcss-freebsd-x64 -o tailwind-freebsd-x64 && chmod +x tailwind-freebsd-x64

which should bind to gcc12 (lang/gcc atm) you'll need to have it installed but it shouldn't conflict. If this still doesn't work, let's take this privately as its not really a phx-tailwind issue.

marschro commented 1 year ago

Hi @dch - I used not your tailwind artifact on FreeBSD 13.1 (amd) with https://people.freebsd.org/~dch/pub/tailwind/v3.2.6/tailwindcss-freebsd-x64 and have now this issue.

ld-elf.so.1: /usr/local/lib/gcc11/libstdc++.so.6: version GLIBCXX_3.4.30 required by /var/tmp/gitlab_runner/builds/brxwgu9M/0/devpunx/jail_portal/_build/tailwind-freebsd-x64 not found
ld-elf.so.1: /usr/local/lib/gcc11/libstdc++.so.6: version GLIBCXX_3.4.30 required by /var/tmp/gitlab_runner/builds/brxwgu9M/0/devpunx/jail_portal/_build/tailwind-freebsd-x64 not found
** (Mix) `mix tailwind default --minify` exited with 1

I have gcc an gcc11 both available... any ideas?

@leonardorame can totally understand. One can build Elixir apps in hours and then has to spend hours or days to try to get this javascript tailwind crossover thingy running...

UPDATE: ... okay, used accidentally this one:

That's now way way way better to handle. I now just have a special mix step in my mix.exs that installs the freebsd bin and done!.

So good !!!!