Skip to content

Dollar Sign is not accepted in ldflags #114

@MaxDamageDevStuff

Description

@MaxDamageDevStuff

As stated in the title, Bake is trying to evaluate the $ORIGIN part as an environment variable, which is not what I assume it should do, due to the single quotes surrounding it.
This is the project.json:

{
    "id": "sandbox",  
    "type": "application",  
    "value": {  
        "language": "c",  
        "use" : ["ecse"]  
    },  
    "lang.c": {  
        "ldflags": ["-Wl,-rpath,'$ORIGIN'/lib"]  
    }  
}

If I use the exact same compiler command that bake fails to execute (gcc -Wall -O0 -Wl,-rpath,'$ORIGIN'/lib .bake_cache/x64-Linux-debug/obj/sandbox.o -L/home /user/bake/x64-Linux/debug/lib -L/home/user/bake/lib -lecse -o ./bin/x64-Linux-debug/sandbox), I get the correct result and it works as expected. What I'm trying to do is get the shared libraries from the lib directory contained in the program directory at runtime. To solve this problem, I tried several escape sequences for both the quotes and the dollar sign, moving the flag in "cflags", and even using clang, but the program doesn't build giving the following output:

[  build] application sandbox => '.'
[   100%] sandbox.c
[  error] environment variable 'ORIGIN' is not set
[   from] invalid command 'gcc -Wall -O0 -Wl,-rpath,'$ORIGIN'/lib .bake_cache/x64-Linux-debug/obj/sandbox.o -L/home/user/bake/x64-Linux/debug/lib -L/home/user/bake/lib -lecse -o ./bin/x64-Linux-debug/sandbox'
[   from] command for task './bin/x64-Linux-debug/sandbox' failed
[   from] failed to build rule 'ARTEFACT'
[  error] build interrupted for sandbox in .
[  error] project sandbox built with errors

In debug mode it gives the following output:

          src/main.c:1383: bake 2.5.0
          src/main.c:1383: | cmd  /home/user/bake/bake build --debug 
          src/main.c:1385: | cwd  /home/user/c_prog/ecse/examples/sandbox
          src/main.c:1386: +
          src/main.c:1414: init
          src/main.c:1414: | configuration debug
          src/main.c:1415: | environment default
          src/main.c:1419: | path .
          src/main.c:1420: | action build
          src/main.c:1421: +
        src/config.c:311 : config
        src/config.c:311 : | load configuration '/home/user/bake/bake.json'
        src/config.c:545 : | debug configuration not found in bake settings file, using defaults
          src/main.c:1478: +
        src/config.c:667 : environment
        src/config.c:667 : | set 'BAKE_HOME' to '/home/user/bake'
        src/config.c:667 : | set 'BAKE_TARGET' to '/home/user/bake/x64-Linux/debug'
        src/config.c:667 : | set 'BAKE_PLATFORM' to 'x64-Linux'
        src/config.c:667 : | set 'PATH' to '/home/user/bake/x64-Linux/debug/bin:/home/user/bake:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/rocm/bin:/usr/lib/rustup/bin'
        src/config.c:667 : | set 'CLASSPATH' to '/home/user/bake/java'
        src/config.c:667 : | set 'LD_LIBRARY_PATH' to '/home/user/bake/lib:/home/user/bake/x64-Linux/debug/lib'
        src/config.c:669 : +
        src/config.c:672 : compiler
        src/config.c:672 : | CC=(null)
        src/config.c:673 : | CXX=(null)
        src/config.c:674 : +
        src/config.c:677 : configuration
        src/config.c:677 : | set 'symbols' to 'true'
        src/config.c:678 : | set 'debug' to 'true'
        src/config.c:679 : | set 'optimizations' to 'false'
        src/config.c:680 : | set 'coverage' to 'false'
        src/config.c:681 : | set 'strict' to 'false'
        src/config.c:682 : | set 'sanitize-memory' to 'false'
        src/config.c:683 : | set 'sanitize-thread' to 'false'
        src/config.c:684 : | set 'sanitize-undefined' to 'false'
        src/config.c:685 : | set 'loop-test' to 'false'
        src/config.c:686 : | set 'assembly' to 'false'
        src/config.c:687 : +
          src/main.c:1534: fork bake to export environment
..l/src/posix/proc.c:54  : /home/user/bake/bake build --debug [70585]

          src/main.c:1383: bake 2.5.0
          src/main.c:1383: | cmd  /home/user/bake/bake build --debug 
          src/main.c:1385: | cwd  /home/user/c_prog/ecse/examples/sandbox
          src/main.c:1386: +
          src/main.c:1414: init
          src/main.c:1414: | configuration debug
          src/main.c:1415: | environment default
          src/main.c:1419: | path .
          src/main.c:1420: | action build
          src/main.c:1421: +
        src/config.c:311 : config
        src/config.c:311 : | load configuration '/home/user/bake/bake.json'
        src/config.c:545 : | debug configuration not found in bake settings file, using defaults
          src/main.c:1478: +
        src/config.c:667 : environment
        src/config.c:667 : | set 'BAKE_HOME' to '/home/user/bake'
        src/config.c:667 : | set 'BAKE_TARGET' to '/home/user/bake/x64-Linux/debug'
        src/config.c:667 : | set 'BAKE_PLATFORM' to 'x64-Linux'
        src/config.c:667 : | set 'PATH' to '/home/user/bake/x64-Linux/debug/bin:/home/user/bake:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/rocm/bin:/usr/lib/rustup/bin'
        src/config.c:667 : | set 'CLASSPATH' to '/home/user/bake/java'
        src/config.c:667 : | set 'LD_LIBRARY_PATH' to '/home/user/bake/lib:/home/user/bake/x64-Linux/debug/lib'
        src/config.c:669 : +
        src/config.c:672 : compiler
        src/config.c:672 : | CC=(null)
        src/config.c:673 : | CXX=(null)
        src/config.c:674 : +
        src/config.c:677 : configuration
        src/config.c:677 : | set 'symbols' to 'true'
        src/config.c:678 : | set 'debug' to 'true'
        src/config.c:679 : | set 'optimizations' to 'false'
        src/config.c:680 : | set 'coverage' to 'false'
        src/config.c:681 : | set 'strict' to 'false'
        src/config.c:682 : | set 'sanitize-memory' to 'false'
        src/config.c:683 : | set 'sanitize-thread' to 'false'
        src/config.c:684 : | set 'sanitize-undefined' to 'false'
        src/config.c:685 : | set 'loop-test' to 'false'
        src/config.c:686 : | set 'assembly' to 'false'
        src/config.c:687 : +
     util/src/load.c:465 : discovery
     util/src/load.c:465 : | first time locating 'bake.lang.c'
     util/src/load.c:561 : | try locating binary for 'bake.lang.c'
     util/src/load.c:321 : | test for shared library file '/home/user/bake/lib/libbake_lang_c.so'
        src/driver.c:1038: | driver 'lang.c' loaded (package = 'bake.lang.c')
        src/driver.c:802 : | lang.c: init
 util/src/posix/fs.c:193 : ├> install-metadata
 util/src/posix/fs.c:193 : | | rm /home/user/bake/meta/sandbox/project.json
 util/src/posix/fs.c:116 : | | setperm /home/user/bake/meta/sandbox/project.json 33188
       util/src/fs.c:222 : | | cp ./project.json /home/user/bake/meta/sandbox
         src/build.c:39  : | +
       src/crawler.c:207 : | discovered project 'sandbox' in '.'
       src/crawler.c:384 : | ignoring directory 'include'
       src/crawler.c:384 : | ignoring directory 'src'
          src/main.c:1584: +
        src/driver.c:802 : build
        src/driver.c:802 : ├> init-drivers
        src/driver.c:802 : | | lang.c: init
         src/build.c:70  : | +
     util/src/load.c:465 : ├> load-dependees
     util/src/load.c:465 : | | first time locating 'ecse'
         src/build.c:75  : | +
       src/crawler.c:269 : | initialized project 'sandbox' in '.'
[  build] application sandbox => '.'
        src/driver.c:802 : ├> validate-dependencies
        src/driver.c:802 : | | lang.c: init
     util/src/load.c:413 : | | sources for 'ecse' not found in '/home/user/bake/src/ecse'
     util/src/load.c:429 : | | dev path '/home/user/c_prog/ecse' located
     util/src/load.c:561 : | | try locating binary for 'ecse'
     util/src/load.c:321 : | | test for shared library file '/home/user/bake/x64-Linux/debug/lib/libecse.so'
       src/project.c:1489: | | use ecse => /home/user/bake/x64-Linux/debug/lib/libecse.so (modified=1736455470)
         src/build.c:133 : | +
        src/driver.c:828 : ├> generate
        src/driver.c:828 : | | lang.c: generate
         src/build.c:138 : | +
 util/src/posix/fs.c:193 : ├> clear
 util/src/posix/fs.c:193 : | ├> uninstall
 util/src/posix/fs.c:193 : | | | rm /home/user/bake/x64-Linux/debug/etc/sandbox
 util/src/posix/fs.c:193 : | | | rm /home/user/bake/include/sandbox.dir
 util/src/posix/fs.c:193 : | | | rm /home/user/bake/include/sandbox
       src/install.c:185 : | | +
         src/build.c:144 : | +
 util/src/posix/fs.c:66  : ├> install-prebuild
 util/src/posix/fs.c:66  : | | symlink /home/user/bake/include/sandbox.h /home/user/c_prog/ecse/examples/sandbox/include/sandbox.h
 util/src/posix/fs.c:66  : | | symlink /home/user/bake/include/sandbox /home/user/c_prog/ecse/examples/sandbox/include/sandbox
         src/build.c:150 : | +
     util/src/load.c:561 : ├> build
     util/src/load.c:561 : | | try locating binary for 'ecse'
     util/src/load.c:321 : | | test for shared library file '/home/user/bake/x64-Linux/debug/lib/libecse.so'
        src/driver.c:880 : | | lang.c: build
       util/src/fs.c:125 : | | mkdir ./bin
       util/src/fs.c:125 : | | mkdir ./bin/x64-Linux-debug
      src/filelist.c:85  : | | sandbox (modified=0, path='./bin/x64-Linux-debug')
     util/src/expr.c:360 : | ├> ARTEFACT
     util/src/expr.c:360 : | | ├> in
     util/src/expr.c:360 : | | | ├> objects
     util/src/expr.c:360 : | | | | ├> in
     util/src/expr.c:360 : | | | | | ├> SOURCES
     util/src/expr.c:360 : | | | | | | | match compile expression '//*.c|*.cpp|*.cxx'
      src/filelist.c:83  : | | | | | | | sandbox.c (modified=1736280417, path='./src')
          src/rule.c:498 : | | | | | | +
          src/rule.c:419 : | | | | | +
      src/filelist.c:85  : | | | | ├> out
      src/filelist.c:85  : | | | | | | sandbox.o (modified=0, path='.bake_cache/x64-Linux-debug/obj')
[   100%] sandbox.c
       util/src/fs.c:125 : | | | | | | mkdir .bake_cache
       util/src/fs.c:125 : | | | | | | mkdir .bake_cache/x64-Linux-debug
       util/src/fs.c:125 : | | | | | | mkdir .bake_cache/x64-Linux-debug/obj
..l/src/posix/proc.c:54  : | | | | | | gcc -fPIC -fvisibility=hidden -g -O0 -std=gnu99 -Wall -W -Wextra -pedantic -Wno-missing-field-initializers -Wno-unused-parameter -D__BAKE__ -D__BAKE__ -fstack-protector-all -DBAKE_PROJECT_ID="sandbox" -Dsandbox_EXPORTS -I./include -I /home/user/bake/include -c ./src/sandbox.c -o .bake_cache/x64-Linux-debug/obj/sandbox.o [70607]
          src/rule.c:434 : | | | | | +
          src/rule.c:498 : | | | | +
          src/rule.c:419 : | | | +
          src/rule.c:302 : | | | sandbox does not exist for ARTEFACT, rebuilding
          src/rule.c:339 : | | | ./bin/x64-Linux-debug/sandbox
      util/src/env.c:130 : | | | [  throw] environment variable 'ORIGIN' is not set
        src/driver.c:510 : | | | [  throw] invalid command 'gcc -Wall -O0 -Wl,-rpath,'$ORIGIN'/lib .bake_cache/x64-Linux-debug/obj/sandbox.o -L/home/user/bake/x64-Linux/debug/lib -L/home/user/bake/lib -lecse -o ./bin/x64-Linux-debug/sandbox'
          src/rule.c:350 : | | | [  throw] command for task './bin/x64-Linux-debug/sandbox' failed
       src/project.c:1914: | | [  throw] failed to build rule 'ARTEFACT'
      util/src/env.c:130 : [  error] environment variable 'ORIGIN' is not set
        src/driver.c:510 : [   from] invalid command 'gcc -Wall -O0 -Wl,-rpath,'$ORIGIN'/lib .bake_cache/x64-Linux-debug/obj/sandbox.o -L/home/user/bake/x64-Linux/debug/lib -L/home/user/bake/lib -lecse -o ./bin/x64-Linux-debug/sandbox'
          src/rule.c:350 : [   from] command for task './bin/x64-Linux-debug/sandbox' failed
       src/project.c:1914: [   from] failed to build rule 'ARTEFACT'
[  error] build interrupted for sandbox in .
       src/crawler.c:628 : [  error] project sandbox built with errors
  /home/user/bake/bake(+0x35115) [0x5d7cabdfc115]
  /home/user/bake/bake(+0x35a49) [0x5d7cabdfca49]
  /home/user/bake/bake(+0xbc44) [0x5d7cabdd2c44]
  /home/user/bake/bake(+0x159c6) [0x5d7cabddc9c6]
  /home/user/bake/bake(+0x1907e) [0x5d7cabde007e]
  /usr/lib/libc.so.6(+0x25e08) [0x795a1c028e08]
  /usr/lib/libc.so.6(__libc_start_main+0x8c) [0x795a1c028ecc]
  /home/user/bake/bake(+0x37b5) [0x5d7cabdca7b5]

..l/src/posix/proc.c:150 : [  throw] process 70585 exited with returncode -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions