-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GR-45043] Build YARP using configure and its Makefile
PullRequest: truffleruby/3891
- Loading branch information
Showing
134 changed files
with
33,157 additions
and
25,301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# truffleruby_primitives: true | ||
|
||
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. This | ||
# code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
# redistribute it and/or modify it under the terms of the: | ||
# | ||
# Eclipse Public License version 2.0, or | ||
# GNU General Public License version 2, or | ||
# GNU Lesser General Public License version 2.1. | ||
|
||
require_relative '../ruby/spec_helper' | ||
|
||
# Similar tests as in https://github.com/ruby/yarp/blob/main/.github/workflows/truffleruby.yml | ||
describe "YARP" do | ||
root = File.expand_path("../..", __dir__) | ||
|
||
guard -> { Dir.exist?("#{root}/src/main/ruby/truffleruby") } do | ||
it "can parse core files" do | ||
Dir.glob("#{root}/src/main/ruby/truffleruby/**/*.rb") do |file| | ||
Truffle::Debug.yarp_parse(File.read(file)).should.include?("Node") | ||
end | ||
end | ||
end | ||
|
||
it "can execute simple code" do | ||
-> { | ||
-> { | ||
Truffle::Debug.yarp_execute("p 1+2").should == 3 | ||
}.should output_to_fd(/^YARP AST:.+Truffle AST:/m, STDERR) | ||
}.should output("3\n") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/.bundle/ | ||
/.idea/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/top-100-gems/ | ||
/tmp/ | ||
/vendor/bundle | ||
|
||
/build/ | ||
/lib/yarp/yarp.* | ||
/lib/yarp.bundle | ||
/lib/yarp.so | ||
test.rb | ||
*.dSYM | ||
*~ | ||
|
||
test.c | ||
a.out | ||
|
||
/ext/yarp/api_node.c | ||
/fuzz/output/ | ||
/include/yarp/ast.h | ||
/java/org/yarp/AbstractNodeVisitor.java | ||
/java/org/yarp/Loader.java | ||
/java/org/yarp/Nodes.java | ||
/lib/yarp/node.rb | ||
/lib/yarp/serialize.rb | ||
/src/node.c | ||
/src/prettyprint.c | ||
/src/serialize.c | ||
/src/token_type.c | ||
/src/**/*.o | ||
|
||
compile_commands.json | ||
.cache/ | ||
|
||
autom4te.cache | ||
configure | ||
config.log | ||
config.status | ||
Makefile | ||
/include/yarp/config.h | ||
/config.h.in | ||
|
||
tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2022-present, Shopify Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
# V=0 quiet, V=1 verbose. other values don't work. | ||
V = 0 | ||
V0 = $(V:0=) | ||
Q1 = $(V:1=) | ||
Q = $(Q1:0=@) | ||
ECHO1 = $(V:1=@ :) | ||
ECHO = $(ECHO1:0=@ echo) | ||
FUZZ_OUTPUT_DIR = $(shell pwd)/fuzz/output | ||
|
||
SOEXT := $(shell ruby -e 'puts RbConfig::CONFIG["SOEXT"]') | ||
|
||
DEFS := @DEFS@ | ||
CPPFLAGS := @DEFS@ -Iinclude | ||
CFLAGS := @CFLAGS@ -std=c99 -Wall -Werror -Wextra -Wpedantic -Wundef -Wsign-conversion -fPIC -fvisibility=hidden | ||
CC := @CC@ | ||
|
||
HEADERS := $(shell find include -name '*.h') | ||
SOURCES := $(shell find src -name '*.c') | ||
SHARED_OBJECTS := $(subst src/,build/shared/,$(SOURCES:.c=.o)) | ||
STATIC_OBJECTS := $(subst src/,build/static/,$(SOURCES:.c=.o)) | ||
|
||
all: shared static | ||
|
||
shared: build/librubyparser.$(SOEXT) | ||
static: build/librubyparser.a | ||
|
||
build/librubyparser.$(SOEXT): $(SHARED_OBJECTS) | ||
$(ECHO) "linking $@" | ||
$(Q) $(CC) $(DEBUG_FLAGS) $(CFLAGS) -shared -o $@ $(SHARED_OBJECTS) | ||
|
||
build/librubyparser.a: $(STATIC_OBJECTS) | ||
$(ECHO) "building $@" | ||
$(Q) $(AR) $(ARFLAGS) $@ $(STATIC_OBJECTS) $(Q1:0=>/dev/null) | ||
|
||
build/shared/%.o: src/%.c Makefile $(HEADERS) | ||
$(ECHO) "compiling $@" | ||
$(Q) mkdir -p $(@D) | ||
$(Q) $(CC) $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< | ||
|
||
build/static/%.o: src/%.c Makefile $(HEADERS) | ||
$(ECHO) "compiling $@" | ||
$(Q) mkdir -p $(@D) | ||
$(Q) $(CC) $(DEBUG_FLAGS) -DYP_STATIC $(CPPFLAGS) $(CFLAGS) -c -o $@ $< | ||
|
||
build/fuzz.%: $(SOURCES) fuzz/%.c fuzz/fuzz.c | ||
$(ECHO) "building $* fuzzer" | ||
$(ECHO) "building main fuzz binary" | ||
$(Q) AFL_HARDEN=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^ | ||
$(ECHO) "building cmplog binary" | ||
$(Q) AFL_HARDEN=1 AFL_LLVM_CMPLOG=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@.cmplog $^ | ||
|
||
build/fuzz.heisenbug.%: $(SOURCES) fuzz/%.c fuzz/heisenbug.c | ||
$(Q) AFL_HARDEN=1 afl-clang-lto $(DEBUG_FLAGS) $(CPPFLAGS) $(CFLAGS) $(FUZZ_FLAGS) -O0 -fsanitize-ignorelist=fuzz/asan.ignore -fsanitize=fuzzer,address -ggdb3 -std=c99 -Iinclude -o $@ $^ | ||
|
||
fuzz-debug: | ||
$(ECHO) "entering debug shell" | ||
$(Q) docker run -it --rm -e HISTFILE=/yarp/fuzz/output/.bash_history -v $(shell pwd):/yarp -v $(FUZZ_OUTPUT_DIR):/fuzz_output yarp/fuzz | ||
|
||
fuzz-docker-build: fuzz/docker/Dockerfile | ||
$(ECHO) "building docker image" | ||
$(Q) docker build -t yarp/fuzz fuzz/docker/ | ||
|
||
fuzz-run-%: FORCE fuzz-docker-build | ||
$(ECHO) "running $* fuzzer" | ||
$(Q) docker run --rm -v $(shell pwd):/yarp yarp/fuzz /bin/bash -c "FUZZ_FLAGS=\"$(FUZZ_FLAGS)\" make build/fuzz.$*" | ||
$(ECHO) "starting AFL++ run" | ||
$(Q) mkdir -p $(FUZZ_OUTPUT_DIR)/$* | ||
$(Q) docker run -it --rm -v $(shell pwd):/yarp -v $(FUZZ_OUTPUT_DIR):/fuzz_output yarp/fuzz /bin/bash -c "./fuzz/$*.sh /fuzz_output/$*" | ||
FORCE: | ||
|
||
clean: | ||
$(Q) rm -f -r build | ||
|
||
.PHONY: clean | ||
|
||
all-no-debug: DEBUG_FLAGS := -DNDEBUG=1 | ||
all-no-debug: OPTFLAGS := -O3 | ||
all-no-debug: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* config.h.in. Generated from configure.ac by autoheader. */ | ||
|
||
/* Define to 1 if you have the `mmap' function. */ | ||
#undef HAVE_MMAP | ||
|
||
/* Define to 1 if you have the `snprintf' function. */ | ||
#undef HAVE_SNPRINTF | ||
|
||
/* Define to 1 if you have the `strncasecmp' function. */ | ||
#undef HAVE_STRNCASECMP | ||
|
||
/* Define to the address where bug reports for this package should be sent. */ | ||
#undef PACKAGE_BUGREPORT | ||
|
||
/* Define to the full name of this package. */ | ||
#undef PACKAGE_NAME | ||
|
||
/* Define to the full name and version of this package. */ | ||
#undef PACKAGE_STRING | ||
|
||
/* Define to the one symbol short name of this package. */ | ||
#undef PACKAGE_TARNAME | ||
|
||
/* Define to the home page for this package. */ | ||
#undef PACKAGE_URL | ||
|
||
/* Define to the version of this package. */ | ||
#undef PACKAGE_VERSION | ||
|
||
/* YP_VERSION */ | ||
#undef YP_VERSION | ||
|
||
/* YP_VERSION_MAJOR */ | ||
#undef YP_VERSION_MAJOR | ||
|
||
/* YP_VERSION_MINOR */ | ||
#undef YP_VERSION_MINOR | ||
|
||
/* YP_VERSION_PATCH */ | ||
#undef YP_VERSION_PATCH | ||
|
||
/* _XOPEN_SOURCE */ | ||
#undef _XOPEN_SOURCE |
Oops, something went wrong.