Skip to content
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

foreign import in folder with spaces #4598

Open
justgook opened this issue Dec 19, 2024 · 1 comment
Open

foreign import in folder with spaces #4598

justgook opened this issue Dec 19, 2024 · 1 comment

Comments

@justgook
Copy link

justgook commented Dec 19, 2024

Context

cannot build application if path to project folder contains spaces, when using foreign import

sokol lib - have this foreign import:

foreign import sokol_app_clib { "sokol_app_macos_arm64_gl_debug.a", "system:Cocoa.framework","system:QuartzCore.framework","system:OpenGL.framework" }

it loads relative path from current file.
problem is that if you work in folder that contains spaces, flags for clang is partially quoted.

odin run . -show-system-calls
[SYSTEM CALL] ld-link
clang -Wno-unused-command-line-argument "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game.o"  -o "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game"  -Wl,-syslibroot /nix/store/4arb21xx2ympiqhv2d0x2zjgw481ibqp-MacOSX-SDK-11.0 -L/usr/local/lib -L/opt/homebrew/lib -lm   -L/ /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/sokol_app_macos_arm64_metal_release.a  -framework Cocoa  -framework QuartzCore  -framework Metal  -framework MetalKit  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/gfx/sokol_gfx_macos_arm64_metal_release.a  -framework Cocoa  -framework QuartzCore  -framework Metal  -framework MetalKit  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/glue/sokol_glue_macos_arm64_metal_release.a  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/log/sokol_log_macos_arm64_metal_release.a   -target arm64-apple-macosx     -no-pie -e _main -Wl,-rpath,@loader_path

Somewhere it is quoted: -o "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game"

and other places do not have quotes -L/ /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/sokol_app_macos_arm64_metal_release.a

odin report output:

        Odin:    dev-2024-11
        OS:      macOS Sequoia 15 (build: 24B91, kernel: 24.0.0)
        CPU:     Apple M2
        RAM:     16384 MiB
        Backend: LLVM 18.1.8

Expected Behavior

path /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/.. is ALWAYS quoted

clang -Wno-unused-command-line-argument "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game.o" -o "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game"  -Wl,-syslibroot /nix/store/4arb21xx2ympiqhv2d0x2zjgw481ibqp-MacOSX-SDK-11.0 -L/usr/local/lib -L/opt/homebrew/lib -lm -L/ "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/sokol_app_macos_arm64_metal_release.a" -framework Cocoa  -framework QuartzCore  -framework Metal -framework MetalKit  "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/gfx/sokol_gfx_macos_arm64_metal_release.a" -framework Cocoa  -framework QuartzCore  -framework Metal -framework MetalKit  "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/glue/sokol_glue_macos_arm64_metal_release.a" "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/log/sokol_log_macos_arm64_metal_release.a" -target arm64-apple-macosx     -no-pie -e _main -Wl,-rpath,@loader_path

Current Behavior

path /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/.. is not always quoted

clang -Wno-unused-command-line-argument "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game.o"  -o "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game"  -Wl,-syslibroot /nix/store/4arb21xx2ympiqhv2d0x2zjgw481ibqp-MacOSX-SDK-11.0 -L/usr/local/lib -L/opt/homebrew/lib -lm   -L/ /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/sokol_app_macos_arm64_metal_release.a  -framework Cocoa  -framework QuartzCore  -framework Metal  -framework MetalKit  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/gfx/sokol_gfx_macos_arm64_metal_release.a  -framework Cocoa  -framework QuartzCore  -framework Metal  -framework MetalKit  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/glue/sokol_glue_macos_arm64_metal_release.a  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/log/sokol_log_macos_arm64_metal_release.a   -target arm64-apple-macosx     -no-pie -e _main -Wl,-rpath,@loader_path

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. crate folder that contains spaces "/Users/gook/test stuff/"
  2. use sokal or other foreign import with relative path
  3. compile odin run . -show-system-calls
  4. observe output, and missing quotes

Failure Logs

$: odin run . -show-system-calls
[SYSTEM CALL] ld-link
clang -Wno-unused-command-line-argument "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game.o"  -o "/Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/game"  -Wl,-syslibroot /nix/store/4arb21xx2ympiqhv2d0x2zjgw481ibqp-MacOSX-SDK-11.0 -L/usr/local/lib -L/opt/homebrew/lib -lm   -L/ /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/sokol_app_macos_arm64_metal_release.a  -framework Cocoa  -framework QuartzCore  -framework Metal  -framework MetalKit  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/gfx/sokol_gfx_macos_arm64_metal_release.a  -framework Cocoa  -framework QuartzCore  -framework Metal  -framework MetalKit  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/glue/sokol_glue_macos_arm64_metal_release.a  /Users/gook/Library/Mobile Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/log/sokol_log_macos_arm64_metal_release.a   -target arm64-apple-macosx     -no-pie -e _main -Wl,-rpath,@loader_path

clang: error: no such file or directory: '/Users/gook/Library/Mobile'
clang: error: no such file or directory: 'Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/app/sokol_app_macos_arm64_metal_release.a'
clang: error: no such file or directory: '/Users/gook/Library/Mobile'
clang: error: no such file or directory: 'Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/gfx/sokol_gfx_macos_arm64_metal_release.a'
clang: error: no such file or directory: '/Users/gook/Library/Mobile'
clang: error: no such file or directory: 'Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/glue/sokol_glue_macos_arm64_metal_release.a'
clang: error: no such file or directory: '/Users/gook/Library/Mobile'
clang: error: no such file or directory: 'Documents/com~apple~CloudDocs/Projects/odin-game/game/sokol/log/sokol_log_macos_arm64_metal_release.a'

@justgook justgook changed the title foreign import foreign import in folder with spaces Dec 19, 2024
@justgook
Copy link
Author

I found the line: lib_str = gb_string_append_fmt(lib_str, " %.*s ", LIT(lib));
by replacing it with: lib_str = gb_string_append_fmt(lib_str, " \"%.*s\" ", LIT(lib));
Fixes issue.
need PR or deeper investigation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant