Giter VIP home page Giter VIP logo

lipo's Introduction

LIPO

This lipo is designed to be compatible with macOS lipo, which is a utility for creating Universal Binary as known as Fat Binary.

This can be useful in the following scenarios:

  • When using a CI/CD platform (such as GitLab) that does not provide access to macOS or macOS lipo.
  • When using GitHub Actions and looking for a cost-effective solution that doesn't involve using macOS.

INSTALL

For example for Linux on amd64,

$ curl -L -o /tmp/lipo https://github.com/konoui/lipo/releases/latest/download/lipo_Linux_amd64
$ chmod +x /tmp/lipo
$ sudo mv /tmp/lipo /usr/local/bin

Install with go install

$ go install github.com/konoui/lipo@latest

USAGE

$ lipo -output <output-binary> -create <arm64-binary> <amd64-binary>

For example,

$ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o amd64 example/main.go
$ CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o arm64 example/main.go
$ lipo -output hello-world -create arm64 amd64
$ ./hello-world
Hello World

$ file hello-world
hello-world: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
hello-world (for architecture x86_64): Mach-O 64-bit executable x86_64
hello-world (for architecture arm64): Mach-O 64-bit executable arm64

Supported Options

-archs, -create, -extract, -extract_family, -output, -remove, -replace, -segalign, -thin, -verify_arch, -arch, -info, -detailed_info, -hideARM64, -fat64

Please run the -help command for more details.

$ lipo -help

lipo's People

Contributors

konoui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tkw1536

lipo's Issues

Reproducability?

Is the output of lipo reproducible? I.e. will the same input always generate the exact same output?

lipo with "-info" / "-archs" result in "invalid magic number"

Hi, and thanks for this great project!

While I suspect it's not as common that the -archs/-info commands are used, I think it's probably good to list it as a difference in functionality from the standard lipo tool.

Currently, when invoking it it produces an error:

$ ./lipo -archs ./mylib.a
Error: can't figure out the architecture type of: ./mylib.a: invalid magic number

# original lipo
$ lipo -archs ./mylib.a
arm64

tests with fat64 will fail on macos-12(macos-latest) on x86_64

reserved in fatArchHeader of apple lipo is non-zero value when testing extract/remove/extract_family.
Tests of replace/create will pass with zero values.

		{
			name:   "-extract_family -fat64",
			inputs: []string{"armv7k", "arm64", "arm64e"},
			arches: []string{"arm64"},
			fat64:  true,
		},
		{
			name:   "-remove -fat64",
			inputs: []string{"armv7k", "arm64", "arm64e"},
			arches: []string{"arm64"},
			fat64:  true,
		},
		{
			name:   "-extract -fat64",
			inputs: []string{"armv7k", "arm64", "arm64e"},
			arches: []string{"arm64"},
			fat64:  true,
		},

hexdump /tmp/want-fat64-remove | less
0000000 feca bfba 0000 0200 0000 0c00 0000 0c00
0000010 0000 0000 0000 0040 0000 0000 1d00 d278
0000020 0000 0e00 0000 0100 0001 0c00 0000 0200
0000030 0000 0000 1d00 00c0 0000 0000 1d00 d278
0000040 0000 0e00 0001 0000 0000 0000 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000

hexdump /tmp/got-fat64-remove | less
0000000 feca bfba 0000 0200 0000 0c00 0000 0c00
0000010 0000 0000 0000 0040 0000 0000 1d00 d278
0000020 0000 0e00 0000 0000 0001 0c00 0000 0200
0000030 0000 0000 1d00 00c0 0000 0000 1d00 d278
0000040 0000 0e00 0000 0000 0000 0000 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000

hexdump /tmp/want-fat64-extract | less
0000000 feca bfba 0000 0200 0001 0c00 0000 0000
0000010 0000 0000 0000 0040 0000 0000 1d00 d278
0000020 0000 0e00 0000 0100 0001 0c00 0000 0200
0000030 0000 0000 1d00 00c0 0000 0000 1d00 d278
0000040 0000 0e00 0001 0000 0000 0000 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000

Fat image creation fails to move file

Hello,

if TMPDIR is on a different filesystem than the output file the operation fails:

root@d27ae656b029:/workspace# /go/bin/lipo -output foo -create foo.amd64 foo.arm64
Error rename /tmp/tmp-output-binary680144686 foo: invalid cross-device link
create:
  Create an universal binary(fat binary) from input thin binaries. 
  e.g. lipo path/to/binary.x86_64 path/to/binary.arm64e -create -output path/to/fat-binary

It's probably os.Rename that needs a fallback:

return os.Rename(out.Name(), l.out)

return os.Rename(out.Name(), path)

Thanks,
Gregor

test failed on on m2 mac book air due to `align 2^13 (8192)`

$ CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o amd64 example/main.go
$ lipo -output hello-world -create arm64 amd64
$  lipo git:(main) โœ— lipo -detailed_info hello-world
Fat header in: hello-world
fat_magic 0xcafebabe
nfat_arch 2
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    capabilities 0x0
    offset 8192
    size 1919680
    align 2^13 (8192)
architecture arm64
    cputype CPU_TYPE_ARM64
    cpusubtype CPU_SUBTYPE_ARM64_ALL
    capabilities 0x0
    offset 1933312
    size 1931474
    align 2^14 (16384)

Can't overwrite file

Original macOS lipo can overwrite input file when it is specified as output. But v0.2.3 can't overwrite file:

lipo -thin x86_64 my_file -output my_file
Error failed to write binary data: EOF

This feature used by pyInstaller.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.